Go to the first, previous, next, last section, table of contents.


The Stack

The stack is where everything happens. Arguments to operators are pushed onto the stack, the operator takes these values off the stack, produces the result and pushes it back on the stack. Most operators will optionally take a operand immediately following as a variable name, and use this for one of their arguments instead of the stack. Most operators are binary, although a few are unary, and there is one tertiary operator. As an example of the stack the fragment below shows four different ways to add 1 to a number (using the binary plus operator and the unary increment operator).

1 <<X + >>X
1 +X >>X
<<X ++ >>X
++X >>X

The first example pushes the numeric literal 1 on the stack, followed by the value of the X variable. Then the + operator takes both of these values off the stack, adds them and pushes the result back on the stack. Then the value is taken off the stack and written back into X. The second example behaves identically except that the form of the operator +X means that the left argument to add is read from the variable X and not from the stack. Note that the result is still put on the stack though. The last two examples use the increment operator instead.


Go to the first, previous, next, last section, table of contents.