POV-Ray : Newsgroups : povray.general : Scope of identifiers in nested Macros : Re: Scope of identifiers in nested Macros Server Time
3 Aug 2024 16:24:26 EDT (-0400)
  Re: Scope of identifiers in nested Macros  
From: Warp
Date: 2 Jan 2004 23:05:12
Message: <3ff63f78@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> #declare, #local: obsolete, deprecated, but unchanged in operation for 
> backwards compatibility.
> #global, #def or #define, #set: as described above, with #def declaring 
> a local variable.

  How would #def be different from #local?

  What's wrong with #local? It's certainly a whole lot more descriptive
than #def.

  I think that a lot of the confusion-causing problems in the current
macro syntax would be avoided if you could specify if the macro takes
its parameter by value (which would be the default in the current syntax)
or by reference (with a special symbol or keyword).
  If the macro says that the parameter is taken by value then POV-Ray
will always make a temporary copy of the parameter. If it says that it
is taken by reference then it would work as it works currently (that is,
if an identifier was given (and not an expression), then any assignment
will be made to the original identifier).

  Example (the & syntax is just a proposition inspired by C++, not
to be taken too seriously):

#macro Foo(Param1, &Param2)
  #set Param1 += 1; // Yes, I want these operators as well :)
  #set Param2 += 2;
  do_something_with_the_params
#end

#local A = 5;
#local B = 5;
Foo(A, B)
// At this point A will be 5, but B will be 7

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

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