|
![](/i/fill.gif) |
Warp napsal(a):
> Tor Olav Kristensen <tor### [at] toberemovedgmail com> wrote:
>>> #macro TEST(A)
>>> #local A = A + 1;
>>> #end
>>>
>>> #declare B = 1;
>>>
>>> TEST(B)
>> ...
>
>> Your code above may work, but was it meant to work that way ?
>> I.e. Is the behaviour above a bug - or is it a feature ?
>> :)
>
>> To me it is illogical that a #local statement should be
>> able to change _anything_ outside its scope.
>
> OTOH, how should it behave?
>
> Macro parameters are passed "by reference". This means that you can
> do this:
>
> #macro TEST(A)
> #declare A = A+1;
> #end
>
> and it will modify the original identifier given as parameter.
>
> You want #local to not to modify the original identifier. So basically
> you want #local to make a local copy of the identifier and modify only that.
> But then all kinds of problematic situations may arise, for instance:
>
> #macro TEST(A)
> #local A = A+1;
> #declare A = A+1;
> #end
>
> Should the #declare modify the local copy or the original identifier?
>
> More importantly: There are two A's now, the original and the local copy.
> Which 'A' should be used in the right-hand-side of the '=' of the #declare,
> the local copy or the original variable? If the #local only modifies a copy,
> then this "local A" will have a different value than the original identifier.
>
The specs says #local always creates the most local variable possible
while #declare writes to the most local existing one. The most local
existing one will be parsed.
--
the ultimate time-killer:
+a0.0 +am2 +r9
Johnny D
Post a reply to this message
|
![](/i/fill.gif) |