POV-Ray : Newsgroups : povray.general : #declaring pre-made macro for identical repeated use? : Re: #declaring pre-made macro for identical repeated use? Server Time
30 Jul 2024 02:17:44 EDT (-0400)
  Re: #declaring pre-made macro for identical repeated use?  
From: Kenneth
Date: 18 Dec 2009 07:20:01
Message: <web.4b2b6f1330d097ea65f302820@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>
> What is happening above is that the values or "items" that your macro
> generates are assigned to your variable "my_identical_macro".
>
> So "my_identical_macro" is now not a macro, it is just a variable that
> contains what your macro "produced".

Thanks, Tor, for clarifying this.  I do see what you mean, and what my mistaken
assumption was. So, to use another very simplistic example, let's say that
my_macro(A,B,C) simply produces a sphere, with the variables A,B,C denoting its
scale:

#macro my_macro(A,B,C)
sphere{0,1 scale <A,B,C>}
#end

Then I #declare that (with a particular set of variables)--and choose a
better name for it, so as not to confuse myself! :-)

#declare my_identical_sphere = my_macro(1,2,3); // no longer a macro now

So when I plug that into my #while loop, all it does is *replace* the macro with
the 'thing' that the macro produced. So in essence, it would be this:

#declare counter = 1;
#while (counter <= 200)
sphere{0,1 scale <1,2,3>} // my_identical_sphere (which is now just a
// pre-#declared 'thing')
#declare counter = counter + 1;
#end

This is actually OK-- i.e, it produces the same *results* as my original
(mistaken) assumption--and now there is no macro invoked at all (which I suppose
is also good--or rather, *efficient*, computationally-speaking.)

Please correct me if my thinking is still wrong.

Ken


Post a reply to this message

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