|
|
Am 14.07.2017 um 20:38 schrieb Bald Eagle:
> #macro SwapXY (X, Y)
> // Input/output: X, Y
> // On output, the values of X and Y have been interchanged.
> #local Z = X; // Z is a placeholder variable
> #local X = Y;
> #local Y = Z;
> #end
>
> My question is, does a mechanism exist by which the true identities of the
> variable names passed to the macro can be accessed?
> Such that if I do:
> #macro SwapXY (OneVariable, Another)
>
> it will actually redefine THOSE variables?
Whenever you pass a variable name as a macro parameter, that macro
parameter will actually behave as a reference to that variable. So the
macro above would indeed work.
The variable name must be defined beforehand though, and the macro can't
undefine it; so the following will fail:
#declare A = 1;
// leave B undefined.
Swap(A,B)
Post a reply to this message
|
|