Programming in stack-based languages is notoriously error-prone: it is way
too easy to lose track of where an operand on the stack came from, and
leave too many or too few operands for an operation.
GXScript <
https://bitbucket.org/ldo17/gxscript> defines operators “</” (which I call “stackbegin”) and “/>” (which I call “stackend”). They are
used as follows:
«n» </
where «n» is a non-negative integer, pops «n» operands off the top of the current operand stack (obviously it must contain at least that many), and
puts these on a new operand stack, which becomes the current stack, while
the previous stack becomes (temporarily) inaccessible, but saved on a
stack of stacks, as it were.
Correspondingly,
«n» />
verifies that the current operand stack contains exactly «n» items; it
pops these off, discards the current operand stack, restores the previous
one, and pushes those values on.
The stack of stacks allows these </ ... /> sequences to be nested to any desired depth.
The “;” operator is quite simple: it asserts that the current operand
stack is currently empty, raising an error if not.
Simple, even trivial, example:
/try
{
2 </
add
1 />
}
ddef
2 3 try = ;
prints
5
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)