It's just plain interpreted text -- no byte codes. In the case of variables, sometimes structures associated with them are cached so that the interpreter doesn't have to look through the entire table of variable names, and that can speed up run time a bit. Since REXX is a "simpler language" than some other interpreted languages like Java, it can be a bit more stream-lined, and therefore faster. Java has to support the whole concept of "objects" so there is an entire complex datatype inflicted upon the entire interpreter.
There is no ++/-- operator. You increment/decrement a numeric variable by adding/subtracting 1 to it as so:myvar = myvar + 1 There is one speed improvement I sometimes make. If I've got a numeric integer (no decimal point) variable, and I know that it's value is less than the NUMERIC DIGITS setting (so it isn't going to need to be rounded), and I need to test if it is a particular value, I'll use a strict comparison (instead of normal comparison). For example, consider the following two lines:IF i = 1 THEN SAY "i = 1"
IF i == 1 THEN SAY "i = 1" The second one is faster because '1' is treated as a literal string that just happens to consist of an ascii numeric character. (Remember that all numbers are really strings in REXX) In the first instruction, both "1" and "i" are stripped of spaces, and then they are checked to make sure that they are rounded to the current NUMERIC DIGITS settings (and if they were expressed in exponential form, then they are converted to "normal" notation with a decimal point), and if they have a fractional part (ie, a decimal point and numbers to the right of it), then any trailing zeros on the fractional part are accounted for in the comparison.
But if you're dealing with simple integers, then that's extra overhead that isn't really needed (because no rounding needs to be done, the numbers aren't in exponential form, and there are no trailing zeros on any decimal part). So the strict comparison is faster.
But an example of where you can get into problems with this speedup is if you try it with non-integer values, or ones that exceed NUMERIC DIGITS setting, or have embedded spaces, for example:myvar = 1.0
IF myvar = 1 THEN SAY "First test is true"
ELSE SAY "First test is false"
IF myvar == 1 THEN SAY "Second test is true"
ELSE SAY "Second test is false" The above displays:
First test is true. Second test is false.
After all 1.0 is the same as 1. But when you do a strict comparison, then they are not the same (because one has a decimal point and an extra 0).
So too, spaces can be a problem:myvar = ' 1 '
IF myvar = 1 THEN SAY "First test is true"
ELSE SAY "First test is false"
IF myvar == 1 THEN SAY "Second test is true"
ELSE SAY "Second test is false" The above displays:
First test is true. Second test is false.
That's because MyVar has embedded spaces. These are not trimmed off in a strict comparison. |