POV-Ray : Newsgroups : povray.general : Strange behavior : Strange behavior Server Time
22 Jun 2024 23:30:43 EDT (-0400)
  Strange behavior  
From: Anthony D  Baye
Date: 15 Jan 2015 22:10:00
Message: <web.54b87fbda54f2dcbd92286f0@news.povray.org>
Say I have a macro that returns values:

#macro someMacroReturningAValue(params)
    #local _RESULT = foo;
    // do stuff here...
    _RESULT
#end

I can use this macro in a computation, thusly:

object { bar translate someMacroReturningAValue(params)*x }

but I cannot set the macro as the rValue of a declaration, like so:

#declare blah = someMacroReturningAValue(params);

because povray doesn't see the semicolon at the end of the declaration.  I can
add the semicolon inside the macro, and the declaration works, but the first
usage breaks.

in order to make the declaration work without breaking the first usage, I have
to encapsulate the macro call in parentheses:

#declare blah = (someMacroReturningAValue(params));

Which, obviously, forces the macro to be evaluated first, but I have no idea why
it makes a difference, and it makes for a very confusing error.

Any explanations?

Regards,
A.D.B.


Post a reply to this message

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