|
 |
Am 04.04.2018 um 03:47 schrieb Kenneth:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmail com> wrote:
>>
>> #macro P()
>> #local B = 0;
>> #end
>>
>> #macro Q()
>> #local B = function { 0 };
>> P()
>> #end
>>
>> Q()
...
> But that construct is essentially the same as this (and the original #macro P()
> can be commented-out, with no change):
>
> #macro Q()
> #local B = function { 0 };
> #local B = 0;
> #end
> Q()
Not exactly. Technically, it is (or at least should be) equivalent to:
#declare LocalQ = dictionary; // start of macro Q
#declare LocalQ.B = function { 0 };
#declare LocalP = dictionary; // start of macro P
#declare LocalP.B = 0;
#undef LocalP // end of macro P
#undef LocalQ // end of macro Q
where LocalQ denotes the local variables context of macro Q, and LocalP
is the local variables context of macro P.
(dictionary is an actual feature in 3.8)
> BTW, there's no error at all when Q() is not actually invoked. That's
> interesting; I thought your original code error might still appear, when POV-Ray
> initially 'reads' #macro Q() in the SDL.
Nope; when initially encounters a macro definition, it only scans the
macro for directives (stuff starting with `#`), and only for the purpose
of skipping to the end of the macro (which is marked by `#end`, but
isn't trivially found because there might be nested statements such as
`#if` or the like that also have an `#end`). As soon as POV-Ray has
figured that out, it doesn't care about the macro contents at all (it
just memorizes the macro's location and length) until the macro is
actually invoked.
Post a reply to this message
|
 |