Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although this may be a "feature creep" and I'm not sure whether many people find it useful or not, I would like to make a "Work in Progress" pull request, hoping this may stimulate other discussions.
As far as I know, there is no way/trick to extract a part of a string in FORM. So I experimentally implemented
substr_(STRING,POS,LEN)macro, which is more or lesssubstrof Perl and PHP but the first character is at POS=1. (Note that it is notsubstring_(STRING,FROM,TO)).POSandLENare somewhat extended to non-positive and negative integers, respectively. Especially,LEN=-1means the actual length ofSTRING.An application is defining a procedure with optional parameters:
which accepts
#call Proc1(x,expand=2)as well as#call Proc1(x),#call Proc1(x,expand)or#call Proc1(x,noexpand).This branch also contains an implementation of
strlen_(STRING), but it is not primitive in the sense that it can be implemented based onsubstr_:Other string operations like
strreplace_(STRING,OLD,NEW)can also be implemented based onsubstr_.