POV-Ray : Newsgroups : povray.advanced-users : Returning values through macro parameters : Returning values through macro parameters Server Time
29 Jul 2024 02:19:53 EDT (-0400)
  Returning values through macro parameters  
From: Andrew Coppin
Date: 9 Mar 2003 16:12:41
Message: <3e6bae49@news.povray.org>
Returning a value through a macro parameter isn't something I've ever done
before. Supposing I have a macro like this:

#macro Thingy(alpha, beta)

how do I change the value of, say, beta so that it's accessible form
outside? Do I use #declare or #local? Does it matter? The manual seems to
imply I should use #declare (I think!) I'm a bit confused...

...

Wouldn't it be better if (uh-oh, here we go! ;-) we did something like:

#global A = 7; // Create new global variable (or error if it already exists)
#local A = 5; // Create new local variable (hide any pre-existing global or
local; error if already exists at this scope level).
#update A = 3; // Change the value of the most local defininition (or error
if none exists).

This syntax means you can clearly tell POV-Ray what you're trying to do, and
so POV-Ray can tell you if what you've asked for is impossible. (For
example, it would be very useful to know that you have two include files
which BOTH try to store information in a global variable, and so are
interfering with each other. At present, POV-Ray can't tell if #global means
"hey POV, replace this existing value..." or "hey POV, make me a new
variable!" If it knew that you meant the latter, it could warn you of your
mistake.)

Personally I think this might be less confusing. (I fully except someone
will shortly post a lengthy irate message explaining exactly why this ISN'T
a good idea, but hey, the suggestion is only my humble opinion.) But then,
maybe I just don't understand how POV-Ray does it now...

Thanks.
Andrew.


Post a reply to this message

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