This function together with the companion function __push_args
is useful for passing the arguments of a function to another function.
__pop_args returns an array of n structures with a
single structure field called value, which represents the value
of the argument.
Example
Consider the following print function. It prints all its
arguments to stdout separated by spaces:
Now consider the problem of defining a function called ones
that returns a multi-dimensional array with all the elements set to
1. For example, ones(10) should return a 1-d array of ones,
whereas ones(10,20) should return a 10x20 array.
This function together with the companion function __pop_args
is useful for passing the arguments of one function to another.
See the desription of __pop_args for more information.
This function may be used to alter the arrangement of objects on the
stack. Specifically, if the integer n is positive, the top
n items on the stack are rotated up. If
n is negative, the top abs(n) items on the stack are
rotated down.
Example
If the stack looks like:
item-0
item-1
item-2
item-3
where item-0 is at the top of the stack, then
_stk_roll(-3) will change the stack to:
This function returns an exact duplicate of the object on top of the
stack. For some objects such as arrays or structures, it creates a
new reference to the array. However, for simple scalar S-Lang types such
as strings, integers, and doubles, it creates a new copy of the
object.