This chapter covers the built-in functions (BIFs): how a call reaches them, how their arguments are checked and which errors they raise, the full list grouped by kind with what is host-specific or differs from native ooRexx, and the functions with substantial machinery of their own (DATE and TIME, RANDOM, VALUE, SYMBOL, SOURCELINE, ERRORTEXT). It assumes the value model and whole-number rules of chapter 2, the call opcodes of chapter 4 and the machine of chapter 5. Streams are only sketched here; their machinery is in chapter 13.
| Piece | ooRexx host | JS host |
|---|---|---|
| Argument checking, numbers, errors, byte layer | ../RVM.BIFs.cls
(CheckArgs, WholeValue, BifError,
RVM.BifMessages) |
../js/bifcore.mjs
(checkArgs, wholeValue, bifError,
MESSAGES) |
| Registry, string and state functions | RVM.BIFTable, IsBIF, CallBIF,
BIF.<NAME> routines |
../js/bifs.mjs
(isBIF, callBIF, register) |
| Arithmetic, conversion, bit functions, XRANGE, DATATYPE | same file | ../js/bifs-number.mjs |
| SYMBOL VAR VALUE SOURCELINE ERRORTEXT RANDOM DATE TIME | same file | ../js/bifs-system.mjs |
Stream and process functions, BifSend |
same file | ../js/bifs-stream.mjs |
| Argument signatures | the parser's .Parser.BIFInfo
(bin/parser/BIFs.cls, LoadBIFInfo) |
BIF_INFO in rvm-data.mjs, generated from
it by ../js/gendata.rex |
| Process services (environment, directory, user...) | RVM.SystemHost in ../RVM.Host.cls |
the host object (../js/host-node.mjs, ../js/host-browser.mjs) |
Translation. The parser's second pass
(CheckCallTypes in bin/parser/SecondPass.cls)
marks a function or subroutine name as
BUILTIN.FUNCTION.NAME /
BUILTIN.SUBROUTINE.NAME when it is not a label of the body
and is in the parser's BIF set (.Parser.BIF); the compiler
then emits FUNCB name n / CALLB name n (compiler). A string name is a
BIF only when it is the name exactly, in upper case:
'LENGTH'(x) is the BIF, 'length'(x) is an
external call (43.1 if nothing is found), as native. A
::ROUTINE of the same name never shadows a BIF. The
parser's optional static check of BIF arguments
(CheckBIFArgs, enabled by the parser option
earlyCheck BIFs) is not enabled by the RVM compiler: every
argument check happens at run time, as in native ooRexx.
Execution. FUNCB/CALLB (in
RVM.Machine~execute and Machine in ../js/machine.mjs) pop the
arguments into an array whose omitted arguments are holes
(PopArgs; JS: undefined entries, the array's
length being the position of the last argument given), and call
CallBIF(name, args, context) / callBIF. Both
look the name up in a table built once: RVM.BIFTable maps
each name to its BIF.<NAME> routine
(CENTRE shares CENTER's); in JS every module
calls register(name, fn) on the BIFS map. The
ooRexx host's table is not built from the routines it
finds: RVM.BIFTable~activate has a hand-written list of
names (names = "ADDRESS ARG CONDITION ...") and looks up
BIF.<NAME> for each. A BIF.<NAME>
routine whose name is not in that list is never called: a
FUNCB of it raises 43.1 ("Could not find routine"). In JS,
register is the whole registration (a new
bifs-*.mjs module must also be imported by
bifs.mjs). The steps for adding a function are in 21. A function is
(name, args, context) → value, where context
is the running RVM.Context / Context
(variables, NUMERIC settings, condition, clock, streams, world). After
the call:
FUNCB pushes the value and, under TRACE I,
traces >F>;CALLB sets RESULT (an object stays an object, anything
else becomes its string) and traces it;RVM.BifSend / BifSend
is not a result but a message to send: the machine sends it from the
instruction (DoSend with mode BIF;
Deliver BIF then pushes the reply, raises 44.1 for
FUNCB when there is none, or sets/drops RESULT). Only the
stream functions and RXQUEUE return one (see Streams).Other routes into a BIF:
CALL (expr) (CALLN): a label of exactly
that name, else a BIF, else routine search (machine).CALL ON condition NAME bif with no such label: the BIF
is called with the condition object as its argument
(TrapRoutine, as native
RexxInstructionCallOn::trap).LINEIN BIF (so a redirected .INPUT is
honoured).LEFT,
POS, C2D...) call the BIF with the receiver
inserted as the subject argument, after checking their arguments in the
native method order (StringMethod and the "B"
dispatch in ../RVM.Objects.cls; the JS
equivalent in ../js/objects.mjs); see Errors for how the method's own error code is
substituted.In all of these a BifSend is sent at once
(BifNow / bifNow, which uses
sendSync), since no instruction is there to carry the
send.
Every BIF starts with
CheckArgs(bif, args, context [, checklist]), a port of the
argument-checking pseudo-code of the ANSI standard (section 9.2.1),
before it does anything else. It returns the arguments
normalised (holes kept), so the function body works on
clean values.
The checklist. By default it comes from the parser's
table: for each BIF, minArgs, maxArgs and one
type per argument, from the BIFARGS.<NAME> strings in
bin/parser/BIFs.cls (r required /
o optional, then the type; ooRexx's signatures override
ANSI's). A function whose rules depend on its arguments passes its own
checklist in the same notation: ARG (rWHOLE>0 rAENO when
an option is given), VALUE, VAR, RANDOM, ERRORTEXT, DATE, TIME, RXQUEUE.
The ooRexx host loads the table with LoadBIFInfo even when
it runs an .rcode file without parsing
(rvm.rex); the JS host reads the generated
BIF_INFO, so both hosts check against the same
signatures.
Count. Fewer than minArgs: 40.3. More
than maxArgs: 40.4. Then each position in order: a hole at
a required position is 40.5; a present argument is checked against its
type. MAX and MIN take any number of arguments, each a required number.
XRANGE takes any number of arguments and checks them itself. (The
functions that ooRexx runs as methods of String are first checked in
ooRexx's way: Errors.)
| Type | Accepts | Normalised to | Error |
|---|---|---|---|
ANY |
any value, not converted (an object stays an object; converting would raise NOSTRING) | itself | - |
STR |
any value: its string (ooRexx's requiredStringArg) |
the string | - |
NUM |
a number, rounded to the caller's DIGITS in its FORM, trailing zeros kept, no LOSTDIGITS | a Number (RVM.Number / RexxNumber) |
40.11; 40.9 if the exponent needs more than 9 digits |
WHOLE, WHOLE>=0 (LENGTH),
WHOLE>0 (POS) |
a whole number at WholeDigits (18 on 64-bit); an object
other than a Stem is its name (ooRexx's numberValue uses
the OBJECTNAME) |
a host whole number (JS: a number, or a BigInt beyond the safe integers) | 40.12, then 40.13 / 40.14 |
D2 (D2C/D2X argument 1) |
WHOLENUM (with a length) or WHOLENUM>=0
(without): whole at the caller's DIGITS |
as above | 40.12 / 40.13 |
PAD |
exactly one character | the string | 40.23 |
BIN / HEX |
a binary / hexadecimal string: blanks (space, tab) only between
groups of 4 / 2 digits counted from the right, none at either end;
"" is valid |
the string | 40.24 / 40.25 |
SYM |
a valid symbol, as ooRexx's LanguageParser::scanSymbol
decides (IsSymbol) |
the string | 40.26 |
ACEFILNOR |
TRACE: any number of ?, then nothing or one of those
letters |
the string | 40.28 |
letters (e.g. BLT, ACDEIORS) |
an option: not null, its first character (any case) one of the letters | that letter, upper case | 40.21 / 40.28 |
STREAM |
a stream name: its string | the string | - |
SEP, RANGE, 0_99 |
left to the function | itself | - |
A whole number is decided by WholeValue (value rounded
to the precision, no exponent, rounded value without fraction), as
ooRexx does: see chapter
2. A Stem object given for a whole-number type is replaced by its
default value without a string conversion (StemValue /
stemValue), so no NOSTRING is raised there, as native.
Arguments are checked left to right.
ooRexx's errors. A built-in function raises the error native ooRexx raises, which is often not the standard's (P1; 17):
BuiltinFunctions.cpp: SUBSTR
is string->substr(n, length, pad); ABBREV through X2D,
MAX, MIN, ABS, SIGN, FORMAT, TRUNC, DATATYPE...) are run that way by
CallBIF / callBIF: first the function's own
checks, in the order of its arguments, with a checklist of
STR, WHOLE and PAD
(RVM.BIFTable~viaMethod, VIA_METHOD: the count
40.3/40.4, an omitted required argument 40.5, a whole number 40.12, a
pad 40.23); then the method of String on the argument that is its
receiver (the second for INSERT, OVERLAY, POS, LASTPOS, WORDPOS,
CHANGESTR and COUNTSTR), with the method's checks and errors (93.9xx, in
the method's order and numbering: RVM.Objects'
StringMethod, 10),
which computes it with the function's own code (ComputeBIF
/ computeBIF). So SUBSTR('abc', 0) is 93.924,
COPIES('a', -2) 93.906 "Method argument 1",
TRUNC('a', 'b') 40.12, ABS('x') 93.943.CallBIF runs it first and
makes the call again in ooRexx's way only when it fails. The common case
costs nothing more.stream->sendMessage(CHARIN, position, count)): after
their own checks (a whole number, 40.12; an option of LINES or STREAM,
40.904) the arguments are converted as ooRexx's API converts them
(MethodStreamArgs: int64_t, size_t, 88.907) and the
stream's errors are its methods' (RVM.Stream~error: 93.958
for a transient stream, 93.0; a position 93.907; an unknown command
93.914; SEEK without an offset 93.903).InternalPackage.cpp): their arguments are converted
as the API does (RoutineArgs: 88.901 missing, 88.907 a
wholenumber_t, 88.922 too many); BEEP's ranges are 88.907, FILESPEC's
option 40.904 (with its first character).Codes. Otherwise, BIFs raise the ANSI 40.x errors
with the standard's texts (the RVM.BifMessages table /
MESSAGES), plus a few ooRexx codes and texts where ooRexx
defines behaviour the standard does not: 40.43 and 40.44 (DATE/TIME
separators), 40.903 (ERRORTEXT range), 40.904 (DATE/TIME and RXQUEUE
options), 40.915 (character functions on QUEUE:), 40.900 (a
message of its own: a message of its own). A key can have a variant
("40.28/CLASS", "40.32/RANDOM",
"40.26/2"): same code, another text.
BifError(code, bif, inserts...) / bifError
fills the text's <...> inserts left to right
(<bif> is the function name) and raises the error;
the condition's ADDITIONAL is the list of values actually filled. The
ooRexx host cannot raise codes that its own rexxmsg.xml
lacks (40.9, for one), so it raises major.900 with
DESCRIPTION "RVM.Message <code> <text>";
BifCodeOf, BifMessageOf and
ErrorAdditional recover the real values wherever a host
condition becomes a Rexx one. JS throws a
RexxError(code, inserts, ownMessage) directly. Details in
chapter 6.
A method's error from the function's code. Where the
method computes with the function's code and that code finds an error
the method words in its own way, the function attaches the method's
error with BifMethodError(method, code, bif, inserts...) /
bifMethodError (third item of ADDITIONAL; JS
e.methodError) and the method's handler
(BifFailed, the JS catch) raises that one
instead; C2D and X2D turn 40.35 into 93.936 / 93.935.
All 84 names of the parser's table are implemented in both hosts,
with the same semantics. The string functions are written against a
minimal byte layer (length, slice inside the string,
concatenation, repetition, reversal, search from a position, a buffer):
PadSlice, Tail, WordSpans,
ScanSet, MapBytes, Range (JS:
padSlice, tail, ...). Padding, defaults,
ranges, words and translation tables are spelled out, never delegated to
a host function of the same name. Words are separated by blanks = space
and horizontal tab only (LF, CR, VT, FF, NUL, A0x separate
nothing). Strings are bytes (chapter 2).
"Host" in the last column means the result depends on the host the RVM runs on (ooRexx host / Node / browser).
| Function | Notes |
|---|---|
| ABBREV, CENTER/CENTRE, COMPARE, COPIES, INSERT, LEFT, LENGTH, OVERLAY, REVERSE, RIGHT, SPACE, SUBSTR, SUBWORD, WORD, WORDINDEX, WORDLENGTH, WORDPOS, WORDS, DELWORD | standard |
| CHANGESTR, COUNTSTR | ooRexx; CHANGESTR's 4th argument is a maximum count |
| DELSTR | the position is optional (default 1) |
| POS, LASTPOS | ooRexx start and length (a range to search) |
| STRIP | the 3rd argument is a set of characters (any
string, "" included), not a pad |
| TRANSLATE | 5th/6th: start and length. A pad with no tables pads every byte (native and ANSI), it does not uppercase |
| UPPER, LOWER | ooRexx; start and length; ASCII letters only |
| VERIFY | 5th: length. A null reference gives the start position for
N unless the start is past the end (ooRexx's
StringUtil::verify) |
| Function | Notes |
|---|---|
| B2X, X2B, C2X, X2C | over the BIN/HEX validation; output in
upper case; X2C pads to an even count with a leading 0 |
| D2C, D2X | the whole number at the caller's DIGITS; with a length, the
rightmost bytes/digits in two's complement
(F/FFx extension for negatives); without, a
negative is 93.927 (the method's) |
| C2D, X2D | unsigned without a length; with one, the rightmost bytes/digits as two's complement; more than DIGITS digits is 93.936 / 93.935 (the method's; the function's own code says 40.35) |
| BITAND, BITOR, BITXOR | ANSI 9.6.2: with a pad the shorter string is extended, without it the rest of the longer one is appended unchanged |
| XRANGE | ooRexx's form: arguments read left to right as pieces; a piece is a
POSIX class name (ALNUM ALPHA BLANK CNTRL DIGIT GRAPH LOWER PRINT PUNCT
SPACE UPPER XDIGIT, any case) or a start byte and the next argument as
end byte, wrapping past FFx; no arguments: all 256 bytes.
Errors 40.28 (/CLASS text) and 40.23. Native has a bug with
exactly two arguments class-then-character
(XRANGE('digit','a') drops the class); the RVM follows the
documentation |
These work at the caller's NUMERIC settings: the NUM
arguments arrive rounded to DIGITS in the caller's FORM, trailing zeros
kept (ABS(-1.50) is 1.50), without LOSTDIGITS.
Arithmetic itself is in chapter
2.
| Function | Notes |
|---|---|
| ABS, SIGN | on the rounded argument |
| MAX, MIN | compared like < at DIGITS−FUZZ; among equal values
the first wins (MAX(1, 2.0, 2) is 2.0).
Native's RexxInteger fast path (a single integer not
rounded, all-integer comparisons ignoring FUZZ) is not followed: an
accepted divergence |
| TRUNC | ooRexx's truncInternal: cut on the rounded number's
digits, never exponential (TRUNC(1E20) is
100000000000000000000 at any DIGITS); the sign goes when
only zeros remain (TRUNC(-0.5) is 0). Not the
standard's (10**n * x) % 1 |
| FORMAT | literal port of ooRexx's NumberString::formatInternal
(BIF.FORMAT, JS FORMAT), including the
bug-#1474 kludge: rounding at after can switch to or keep
exponential notation. No room in before or
expp: 40.38 (method: 93.942 / 93.941) |
| DATATYPE | no type: NUM or CHAR; types A B I L M N O
S U V W X 9 (ooRexx's set). N accepts what a NUM argument
accepts; W at DIGITS, I at WholeDigits, 9 at 9 digits, all
by WholeValue; V a symbol not starting with a digit or
period. "" is 0 except for B and X |
| RANDOM | see RANDOM |
| Function | Notes |
|---|---|
| ADDRESS | no arguments (ooRexx 5's signature: any argument is 40.4) |
| ARG | ARG(), ARG(n),
ARG(n, E/O/N/A). N returns an object argument
as the object. A (ooRexx): an Array of the arguments from n
on, omitted ones as holes, empty when n is past the count (native
new_array) |
| CONDITION | C D E I S, plus ooRexx's A (ADDITIONAL) and O (the condition object)
and R (forget the current condition, returns ""). See chapter
6 |
| DIGITS, FUZZ, FORM | the activation's settings |
| QUEUED | lines in the current external data queue |
| TRACE | returns the old setting; sets a new one as the TRACE instruction
does (setTrace, a port of
TraceSetting::parseTraceSetting; machine). Bad setting: 24.1, as the
instruction (the character found) |
| SOURCELINE, ERRORTEXT | see below |
| SYMBOL, VAR, VALUE | see Variables by name |
| DATE, TIME | see DATE and TIME |
CHARIN, CHAROUT, CHARS, LINEIN, LINEOUT, LINES, STREAM. The name is
resolved in the activation's stream table
(Streams(context), see 13;
the null name is the default input or output); the work is done by
RVM.Stream / Stream (chapter 13). A NOTREADY ends the call
with the function's default ("" for CHARIN/LINEIN, the
characters not written for CHAROUT, 1 for LINEOUT, 0 for
CHARS/LINES).
QUEUE: (any case) is the external data queue for the
line functions (LINEIN pulls, LINEOUT queues, LINES counts); CHARIN,
CHAROUT and CHARS on it are 40.915.STDIN, STDOUT,
STDERR (with or without the colon) are
.local's INPUT, OUTPUT and ERROR (native
resolveStream). While those are not observable the function
goes straight to the host; otherwise it returns an
RVM.BifSend (LocalStream,
LocalSend) that the machine sends from the instruction (reflection).
LINES(name, 'N') sent that way is normalised to 1 or 0
afterwards (post LINESN,
BifSend~finish).SecureStream:
STREAM with the qualified NAME); a replacement
object it gives is used through messages, once per name per scope,
forgotten on close (objects).LINEOUT(name) and a STREAM ... CLOSE
forget the stream; a failed OPEN forgets it too. STREAM's third argument
is allowed only with C (40.4) and required with it (40.3);
STREAM('') is 40.27.| Function | Notes | Host |
|---|---|---|
| QUALIFY | absolute name, ~, . and ..
resolved, whether it exists or not; "" for ""
(FileSystem~qualify) |
file layer |
| FILESPEC | D L P N E (option letter; 40.904 with its first character; the arguments as a native routine's, 88.9xx). Path up to the last separator, drive up to the first colon where the platform has drives; extension after the last dot of the name; the spec is read as a C string (up to the first NUL) | separators and drives from the file layer |
| DIRECTORY | changes to the qualified directory, then returns the current one;
"" if it cannot |
ooRexx host: host DIRECTORY(); Node:
process.chdir; browser: its virtual file system |
| USERID | the user name | ooRexx host: host USERID(); Node:
os.userInfo().username; browser: rexx |
| BEEP | frequency 37–32767, duration 0–60000 (88.907, a native routine's errors) | ooRexx host: the host's BEEP; JS: no sound |
| GC | GC('F'): 1 if a collection ran |
ooRexx host: host GC('F'); JS: returns 1 when forced,
collects nothing |
| SETLOCAL, ENDLOCAL | save / restore the current directory and environment variables; 1, or 0 when nothing to restore or unsupported | 0 on Windows (both hosts); the browser host supports them |
| VALUE(..., 'ENVIRONMENT') | process environment, see Variables by name | ooRexx host: host VALUE; Node: process.env
(bytes as Latin-1 ↔︎ UTF-8); browser: an in-memory map |
| RXFUNCADD, RXFUNCDROP, RXFUNCQUERY | external function registry | per process (native: the global rxapi daemon); see chapter 12 |
| RXQUEUE | C D E G O S; returns a BifSend of ooRexx's messages
(.STDQUE GET/SET; RexxQueue class
CREATE/OPEN/EXISTS/DELETE); a queue name must be a symbol of at most 250
characters (40.26 with the /2 text); see chapter 13 |
- |
SETLOCAL/ENDLOCAL. Every environment change the RVM
makes goes through the host's setEnv, so that it can be
undone: SETLOCAL pushes a snapshot (current directory, and a journal
that records the old value of each variable the first time it changes
while the snapshot is active); ENDLOCAL pops the latest snapshot,
restores the directory and gives back their old values to the variables
that existed when it was taken (variables created since then are left
alone). At program end the oldest active snapshot is restored
(endProgram). A journal is needed because the ooRexx host
cannot list the environment; the existence of a variable whose value is
null is asked of a child process (envExists).
Both are ooRexx's (options, conversions, error order), computed by the RVM itself: only "now" comes from the host.
One number. A time is the number of microseconds
since 0001-01-01 00:00:00.000000, local time, proleptic Gregorian
calendar (ooRexx's DATE('F')); the host gives that and the
UTC offset (HostNow: the host's .DateTime~new;
JS host.now() from
performance.timeOrigin + performance.now() and
Date~getTimezoneOffset, as BigInts). Days, fields, names
and weekdays are computed by DaysFromCivil /
CivilFromDays (an era-based civil calendar algorithm,
validated over 0001–9999), MonthName,
WeekDayName (0001-01-01 is a Monday). The JS port does the
arithmetic in BigInt where the Rexx original uses NUMERIC DIGITS 20 or
40.
One time per clause.
ClauseTime(context) takes the host time the first time a
clause needs it and keeps it in the activation's clock
(RVM.Clock; JS a plain object on the context): every DATE
and TIME of the same clause see the same instant, as native
(RexxActivation::getTime). The clause boundary marks the
stamp stale (valid false); a call gives the callee a copy
of the clock with a stale stamp and restores the caller's on return.
Under RVM_CLOCK=virtual the scheduler's skipped time is
added to the host time, so SysSleep advances TIME and DATE
(concurrency).
Elapsed time. TIME('E') and
TIME('R') use elapsedStart in the clock. The
first reading in an activation starts it and gives 0. R
sets elapsedReset: the restart happens lazily, at the time
of the clause of the R, just before the next clause takes a
new time, so a TIME('E') in the same clause as
TIME('R') still reads the old value (native behaviour). An
internal routine gets a copy of the caller's elapsed clock (its own
R does not affect the caller); an external routine or
method starts a fresh one (startProgram resets it). A clock
reading negative (local time went back) gives 0 and restarts.
Output formats. DATE: B D E F I L M N O S T U W (default N); TIME: C E F H L M N O R S T (default N). Only the first character of an option counts; an empty or unknown option is 40.904, the unknown one only after the other checks, in ooRexx's order. An output separator (DATE argument 4) is allowed only for E I N O S U (40.44) and must be null or one non-alphanumeric character (40.43); an input separator (argument 5) is not allowed for B D F L M T W.
Input conversions (DateInput,
TimeInput). The formats with fields are read by
ParseDateTime, a port of ooRexx's
RexxDateTime::parseDateTimeFormat (the same format letters
and rules: two-digit years windowed on the current year −50..+49,
M month abbreviations case-sensitive, the date must exist,
nothing may be left over). B and D are whole numbers at 9 digits; F and
T 64-bit integers (Int64Value, whole at 20 digits within
±2**63); D counts days of the current year. Not readable: 40.19, or
40.44 when an input separator was given; E/R
with an input time is 40.29.
Native quirks that are reproduced:
DATE('S', '20260923'||'00'x||'junk', 'S') reads
20260923; a "00"x separator is refused (40.43,
since ooRexx's strchr finds the terminator);TIME('F', ...) is the time alone); H, M and S input leave
an empty date (year, month, day 0), which ooRexx's arithmetic makes day
−366: TIME('F', 5, 'H') is -31604400000000
(this comes from reading before a C table; it is what ooRexx 5.3 on
Linux gives);O moves the clause's time to
another offset by ooRexx's formula (local + current offset − new
offset), keeping the time when the result is out of range;
TIME('O') reports the offset in microseconds with ooRexx's
sign.Deliberate departures (native bugs): DATE(, 0, 'D') is
40.19 (native makes a month-0 date on which DATE('M')
crashes the interpreter), and T input beyond about 9.2E12 seconds is
40.19 (native wraps its 64-bit arithmetic to another date).
RANDOM([min] [, [max] [, seed]]) reproduces ooRexx's
generator bit for bit (RexxActivation::getRandomSeed,
BuiltinFunctions.cpp), so a seed gives the same sequence as
native:
next(s) = (s * 25214903917 + 11) mod 2**64
seed s: state = next^13(NOT s) (all 64 bits flipped)
each call: state = next(state); result = min + reverse64(state) // (max - min + 1)
Every call advances the state once, with or without a range,
including RANDOM(n, n) (which returns n) and calls that
then fail a range check. Arguments follow ooRexx: alone, the first
argument is the maximum (RANDOM(10) is
0..10); min and max default to 0 and 999 and may be negative; max <
min is 40.33; max − min over 999,999,999 is 40.32 with ooRexx's text and
limit (the standard's is 100000); the seed must be ≥ 0. The ooRexx host
computes at NUMERIC DIGITS 40 (RandomNext,
RandomNot, RandomReverse), JS with BigInt.
Without a seed the state starts from four 16-bit draws (the host's
RANDOM; JS Math.random).
The state belongs to the activation
(context~randomSeed), as in native: the program, each
method and each external routine (a ::ROUTINE, a Routine
object, an external program, a ::REQUIRES prolog) have
their own, which starts from a fresh unpredictable value
(startProgram) and is put back when they return
(popActivation); an internal routine and INTERPRET use, and
advance, their caller's. A seeded sequence is therefore not disturbed by
the draws of the methods and routines the program calls, and a seed set
in a method or routine does not carry over to another. REPLY keeps the
method's state (activationState).
NameRef(name, context) (JS nameRef, also
used for DROP (x)) says what a string names:
BAD (not a symbol), CONST (constant or
environment symbol: starts with a digit or period), SIMPLE,
STEM, or COMPOUND with the tail derived as in
a program (each component that does not start with a digit is replaced
by the value of that variable). A stem exists as soon as it is
referenced (read, written, dropped, even SYMBOL('zz.1')),
as native; a stem's DROP empties it in place.
BAD, VAR (a
variable with a value; a stem that exists), else LIT
(constant symbols too).SYMBOL(name) == 'VAR', 0 for a non-symbol; its argument is
ANY (a non-symbol is not an error).new if given (any
object; assigning to a constant symbol is 40.26, as native). A name that
starts with a period and is not a number is an environment symbol and is
resolved as one (VALUE('.true') is 1,
VALUE('.foo') is .FOO; native
getVariableRetriever).ENVIRONMENT (any case) reads and writes process environment
variables through the host (setEnv, journaled for
SETLOCAL); a new value of .nil removes the variable (native
setEnvironmentVariable). Any other new value is taken as
native's stringArgument takes it
(requestString: a string, or an object that answers REQUEST
STRING, such as an Array, whose lines are joined); an object with no
string value is 88.909. The null selector is ooRexx's global
.environment (upper-cased name; .NAME when
there is no entry; any object can be stored). Any other selector is
40.914.SOURCELINE([n]): without n, the number of lines of
the running program (context~sourceLines: the program's, or
an external routine's or package's when it runs); with n, line n; n past
the end is 40.34. The count is 0 when the program runs from R-code
without its source (an .rcode file run directly by the
ooRexx host; the JS launcher given R-code without the source
option).
ERRORTEXT(n): ooRexx's rules, not the standard's: n
a whole number 0–99 (40.12, then 40.903 out of range; the standard
accepts 0:90 with a decimal part and uses 40.16/40.17), ""
for numbers that are not error numbers. The texts are the host
interpreter's: the ooRexx host asks its own ErrorText; JS
uses ERROR_TEXT in rvm-data.mjs, generated
from it.
Results are the same in both hosts for every case probed, except
where the host is the subject: USERID, DIRECTORY, BEEP, GC,
SETLOCAL/ENDLOCAL availability, environment variables, the current time
and the unseeded RANDOM state (tables above). Implementation
differences: the JS functions return whole numbers as JS numbers or
BigInts (toWhole), the clock and RANDOM use BigInt, and the
browser host has an in-memory environment, a virtual current directory
and a fixed user name.
CheckArgs before doing
anything. The signatures are not repeated in the RVM: they are the
parser's table, read directly by the ooRexx host and generated into
rvm-data.mjs for JS, so the compiler's idea of what is a
BIF and the machine's checks cannot disagree.DATATYPE(x,'W'), ARG positions and D2X agree with native.
Two slips of the standard are corrected in the port: its DATATYPE
compares the exponent's value with the limit on exponent
digits (the RVM implements the intent: at most 9 digits, 40.9),
and its ERRORTEXT texts for 40.16/40.17 do not match their codes
(ERRORTEXT uses ooRexx's 40.903 anyway)..local's objects are observable, a stream BIF's work
is a message to a Rexx object; returning a BifSend lets the
machine send it from the instruction like any other send, so the
activity can wait and errors in the redirected stream get a full
traceback, instead of nesting a machine with sendSync.(name, args, context). It needs no frame of its
own; it runs inside the instruction, and errors it raises belong to the
calling clause, as native's BIFs do.rexx; DIRECTORY
there works on the browser host's virtual file system.