POV-Ray : Newsgroups : povray.general : Is this a bug, or am I missing something? : Re: Is this a bug, or am I missing something? Server Time
6 Aug 2024 16:55:13 EDT (-0400)
  Re: Is this a bug, or am I missing something?  
From: Christopher James Huff
Date: 12 Apr 2002 17:45:16
Message: <chrishuff-A4AC49.17470712042002@netplex.aussie.org>
In article <slr### [at] fwicom>,
 Ron Parker <ron### [at] povrayorg> wrote:

> You could argue either way as to how this should work.  Personally, I think
> I'd be in favor of #local severing the 'reference' link, but that would 
> require a bit of nasty code in some unlikely places.

I'd like it if there were separate keywords for making new variables and 
modifying old ones:

#local always creates a local variable. If one with the same name 
exists, it is destroyed and replaced. The original variable of a 
parameter passed by reference will be untouched.
#declare creates a global variable, otherwise same rules as above. Maybe 
change name to #global.

Add a new #set directive for modifying existing variables. If the 
variable doesn't already exist, an error results. This would also avoid 
situations like:

#local MyCounter = 0;
#while(MyCounter < 10)
    ...
    #local myCounter = MyCounter + 1;
#end

Oops...a little typo makes an infinite loop. With #set:

#local MyCounter = 0;
#while(MyCounter < 10)
    ...
    #set myCounter = MyCounter + 1;
#end

You get something like:
Error: attempt to #set non-existent variable "myCounter"

The #set directive is already partially implemented as a patch, though 
it doesn't work perfectly yet. To do all of this would probably require 
reworking large chunks of the parser, probably better to just start over 
from scratch.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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