POV-Ray : Newsgroups : povray.general : Macro Problem : Re: Macro Problem Server Time
23 Apr 2024 09:22:17 EDT (-0400)
  Re: Macro Problem  
From: Le Forgeron
Date: 22 Apr 2018 02:47:37
Message: <5adc3009$1@news.povray.org>
Le 22/04/2018 à 07:47, Sven Littkowski a écrit :
> If you have a little bit time and experience at your hand, you can help
> me to find my error.
> 
> When calling the texture macro directly from another file, it works. But
> when calling it from within the parameter liner of another macro, I get
> the error message you cans see as comment behind one of the lines. Why?
> Why? Why?
> 

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

Foo( Bar() )

The above line, I would avoid, and use instead

#local BarValue = Bar():
Foo( BarValue )

I'm not a big fan of meta-programming in SDL, so even if there could be
legitimate use cases of a macro invocation from within another macro, I
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.

when Bar() has side effect, it results in something different.

Such as

#declare BarCounter = 0;

#macro Bar()
#declare BarCounter = BarCounter+1;
BarCounter
#end

Should the parser become painful and more complex by forbidding such
macro in macro ? I'm not sure.


Post a reply to this message

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