On Sunday, September 18, 2022 at 10:19:43 AM UTC+10,
co...@ccil.org wrote:
> I'm now figuring out the list of plipp's built-in functions, and I realize I need to determine the appropriate data structures the preprocessor needs. Neither the full nor the subset ANSI standard has anything to say about preprocessing other than %INCLUDE, so I have no guidance for this.
>
> In particular, IBM supports arbitrary PL/I arrays, but I think it may be enough to support just one-dimensional arrays, or arrays with a fixed lower bound of 1, or both. None of the other PL/I manuals I have access to talks about arrays at all. Anyone have feedback on how useful the richer arrays are when preprocessing? It's not a matter of implementation difficulty, but of featuritis, particularly documentation complications.
>
> Anyhow, here's the tentative built-in function list:
>
> ABS(n) - absolute value of n
> CHAR(n) - character with codepoint n
> COMMENT(s) - format s as a comment
> COMPILEDATE() - yyyymmddhhmmssttt
> COPY(s,n) - n copies of s
> COUNTER() - string of next integer value
> DIMENSION(a,n) - extent of array a in the nth dimension
> DIV(x,y) - x div y
> FIXED(n) - fixed integer represented by n
> HBOUND(a,n) - high bound of array a in the nth dimension
> INDEX(needle,haystack[,index]) - returns 0 if not found
> LBOUND(a,n) - low bound of array a in the nth dimension
> LENGTH(s) - string length
> LOWERCASE(s) - lowercase of s
> LTRIM(s) - remove whitespace from left end
.
Usually, macro built-ins use the same name as compiler builtins.
It's for consistency.
The Enterprise compiler uses TRIM as a preprocessor name,
not LTRIM and RTRIM.
TRIM removes from either end, or from both ends,
just as does the compiler version.
.
There's no DIV function, nor FIXED, nor MOD.
.
> MAX(x,y) - maximum of x and y
> MIN(x,y) - minimum of x and y
> MOD(x,y) - x modulo y
> QUOTE(s) - format s as a quoted string
> RANK(a) - rank of array
.
There's no RANK.
.
> REPEAT(s,n) - COPY(s,n+1)
> RTRIM(s) - remove whitespace from right end
> SEARCH(x,y,[n]) - position in x of char in y, starting at n
.
There's no SEARCH nor SIGN nor STRING.
.