up previous next
ImportByRef, ImportByValue --
import an external local variable by reference or value
|
ImportByRef X;
ImportByValue X;
where X is the name of a variable in the containing scope.
|
These commands can be used only inside anonymous functions (see
func
).
These commands "import" an external, non-top-level variable by reference
or value.
ImportByValue creates a variable inside the anon func with
the given name, and its initial value is taken from the external variable
of the same name in the context the anonymous function is defined. In
contrast,
ImportByRef creates a
reference (from inside the anon
func) to the named external variable in the context where the anon func
is defined.
See
TopLevel
for accessing top-level variables.
NOTE: Package variables should be accessed directly (via their fully
qualified names); they cannot be imported.
/**/ define add(X)
/**/ AnonFn := func(Y) ImportByValue X; return X+Y; EndFunc;
/**/ return AnonFn;
/**/ EndDefine;
/**/ add3 := add(3);
/**/ add3(2);
5
|