POV-Ray : Newsgroups : povray.newusers : local variables in macros : Re: local variables in macros Server Time
5 Sep 2024 08:15:22 EDT (-0400)
  Re: local variables in macros  
From: Elias Pschernig
Date: 20 May 2001 17:10:38
Message: <3b0832ce$1@news.povray.org>
> Why did you want to avaid a new variable, though? (And you actually
> werent avoiding any - #local always creates a new variable.) For
> elegance? Because of the memory requirements? A single new vector
> variable has a neglible cost in a recursive macro or anywhere else,
> for that matter.

I was avoiding one line of code for every parameter. And i'm going to
need lots of parameters, as there doesn't seem to be a
'record/struct/class' construction in POV :)

Instead of using the code below:

// pseudo code
#macro example(pos)
   #while
      example(pos)
      #local pos = pos + y
   #end
#end

I'm using now, as you suggested:

#macro example(pos)
   #local var_pos = pos // this is what i have to do additionally
   #while
      example(var_pos)
      #local var_pos = var_pos + y // because this should change the
                                   // local value only
   #end
#end

And it works exactly as I want it to :)

Thanks again for your reply,

Elias Pschernig


Post a reply to this message

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