Post Reply 
Free42: Unlimited-length strings and other type extensions
02-09-2021, 01:03 AM (This post was last modified: 02-13-2021 07:18 AM by Thomas Okken.)
Post: #31
RE: Free42: Unlimited-length strings and other type extensions
I'm about to start on long strings... They will be needed anyway in order to fully integrate equations into the type system, and I think I can do them in a way that people will like. There's certainly no danger of the Big Stack controversy here, the Long Strings will be fully backwards compatible, there will be no special mode to use them, just some new capabilities that one can freely use, or safely ignore. And, as with the big stack, if the new capability is not used, the only downside of its presence is the few kilobytes added to the executable.

I'm also going to expose the new List type. That type already exists and I used it to implement FUNC, L4STK, and LNSTK, and it could be manipulated using the same set of functions as strings. The concepts string/characters and list/elements are similar enough to make that pretty intuitive, I think.

(Note that all of this will be in Plus42 only, not in the basic version. Once the basic version is released with the big stack, it will be in maintenance mode; no further enhancements are planned. At least for now. But of course bugs will continue to be fixed.)

Here is a tentative list of functions:

APPEND: adds the object in X to the string or list in Y and returns the combined string or list. If Y is a string, the contents of X will be converted to a string in the same way as ARCL. If Y is a list, X will be added to it unchanged. If X is a list, it will be added to Y as one element.

EXTEND: adds the object in X to the string or list in Y and returns the combined string or list. If Y is a string, the contents of X will be converted to a string in the same way as ARCL. If Y is a list, X will be added to it unchanged. If X is a list, it will be added to Y element by element.

SUBSTR: from the string or list in Z, gets the substring/sublist starting at index Y and ending at index X. If X and/or Y are negative, they are counts from the end, rather than the beginning. The very end of the string or list can be specified by leaving off the 'end' parameter, i.e. by having the string or list in Y and the starting index in X.

LENGTH: returns the length of the string or list in X.

HEAD <param>: removes and returns the first character or element from the string or list named by <param>. If the string or list is empty, skip the next instruction.

REV: reverse the string or list in X

POS: finds the first occurrence of the string or list X in Y. Or with three parameters: find the first occurrence of string or list X in Z, starting the search from position Y.

S→N, N→S: convert string to number or number to string, like ANUM and ARCL
C→N, N→C: convert character to number or number to character, like ATOX and XTOA

XASTO, LXASTO: like ASTO and LASTO, but the entire ALPHA register, not just the first 6 characters.

LIST?: tests whether the object in X is a list

NEWLIST: returns a new empty list

NEWSTR: returns a new empty string
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Free42: Unlimited-length strings and other type extensions - Thomas Okken - 02-09-2021 01:03 AM



User(s) browsing this thread: 1 Guest(s)