POV-Ray : Newsgroups : povray.general : Macro Problem : Re: Macro Problem Server Time
26 Apr 2024 12:17:22 EDT (-0400)
  Re: Macro Problem  
From: clipka
Date: 22 Apr 2018 06:36:13
Message: <5adc659d@news.povray.org>
Am 22.04.2018 um 08:47 schrieb Le_Forgeron:

> Macro call inside macro call...
> I'm not sure the parser is expecting such thing, at least in its design
> & specification.

"What design & specification?"

> do not know which path should be followed to handle Foo( Bar() )
> 
> 1. Bar() is evaluated and its value is used as the parameter (or rather,
> the text of the parameter is replaced with the value of Bar() and parsed
> every time the parameter is used inside the macro Foo.
> 
> 2. Bar() is copied as the parameter, and parsed every time the parameter
> is used inside the macro Foo.

Whenever the tokenizer encounters an existing macro name `Bar` (except
in special contexts such as `#undef Bar`, `#define Bar` or `#macro
Bar`), it immediately invokes the macro, and effectively inserts the
"results" of the macro in-place. So for instance the following SDL code
is perfectly legitimate, as the apparent single parameter `Bar()`
actually happens to resolve to two parameters:

    #macro Bar()
      "4711", "42"
    #end

    #macro Foo(A,B)
      #debug concat(A,"\n")
      #debug concat(B,"\n")
    #end

    Foo(Bar())


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.