|
|
Am 24.07.2018 um 00:49 schrieb Mike Horvath:
> Wow, I thought local variables only worked in the local scope. E.g. the
> globally declared variable in the code you supplied would retain its
> original value.
For clarification - what JimT is describing is the following behaviour:
#macro Foo(A)
#local A = 42;
#end
#declare A = 1; // just for clarification
#declare X = 1;
Foo(X)
#debug concat("A = ",str(A,0,0),"\n") // still 1
#debug concat("X = ",str(X,0,0),"\n") // now 42
So `#local A` in a macro does not change the global variable named `A`.
It does, however, change the macro parameter named `A`. If a global
variable happens to be passed to that macro parameter, that global
variable (no matter what its name outside the macro) is also changed.
This call-by-reference behaviour is intentional, as a means to pass
additional information back out of a macro.
Post a reply to this message
|
|