POV-Ray : Newsgroups : povray.general : Scope of identifiers in nested Macros : Re: Scope of identifiers in nested Macros Server Time
3 Aug 2024 22:10:49 EDT (-0400)
  Re: Scope of identifiers in nested Macros  
From: Christopher James Huff
Date: 3 Jan 2004 18:45:01
Message: <cjameshuff-E01717.18450003012004@netplex.aussie.org>
In article <3ff750b5@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> > It would give a warning or error when used on an existing variable.
> 
>   Wasn't #set for that? I'm confused.

#set or #IDENTIFIER would prevent you from accidentally defining a new 
variable...it would give an error if you tried to modify a nonexistent 
variable.
#def would prevent you from accidentally redefining an existing 
variable. It would give an error or warning if the new variable would 
replace the existing one.


> > >   What's wrong with #local? It's certainly a whole lot more descriptive
> > > than #def.
> > And it's used. Changing it would break backwards compatibility.
>   I don't understand what you are saying.

Well, the warning wouldn't break backwards compatibility, but would slow 
down the parsing of any old scene and drown out more legitimate 
warnings. The error would break any old scene. Or maybe it could be made 
to depend on the version directive...


> > I don't like this idea. One thing about C++ that I've never liked was 
> > the way you couldn't tell by reading the call whether you were passing 
> > by reference or by value.
> 
>   Currently you have only one option: By reference. And this is causing
> confusion.

Not really. It surprised someone, but it's certainly not a common source 
of confusion, and it only happens when someone's doing something a 
little strange anyway (modifying a parameter). It's easy to write the 
macro to work with a local version, and that's what should be done if it 
isn't returning something through the parameter.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

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