| unroll |
(Pointer source [, Pointer dest]) |
reserved |
| |
|
Copies elements from
source
into
dest
or a new array if
dest
is omitted, and returns destination (i.e., either
dest
or the new array) to the caller.
When an object, like a dictionary, that associates names with values
is unrolled into an object, like an array the does not, then
unroll
includes the name and the value of each element in the destination.
Something special happens when
unroll
is used as an argument in a function call.
The Yoix interpreter notices the array argument that was returned by
unroll
and decides that the individual elements in that array that are also initialized,
rather than the array itself, should be the arguments in the function call.
Although it is may not be obvious, this is one of
unroll's
most important uses.
| |
| Example: |
The program,
import yoix.stdio.*;
f(Stream stream, String fmt, ...) {
if (stream == stdout)
printf(unroll(&fmt));
else fprintf(unroll(&stream));
}
f(stdout, "this calls %s\n", "printf");
f(stderr, "this calls %s\n", "fprintf");
prints
this calls printf
on standard output and
this calls fprintf
on standard error.
Even though it is a trivial example it illustrates how
unroll
can be used when you are in a function, often one with a
variable argument list, and you want to call another function,
once again often one with a variable argument list.
| | |
| Return: |
Array
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|