|
![](/i/fill.gif) |
In article <slr### [at] fwi com>,
Ron Parker <ron### [at] povray org> 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] mac com>
POV-Ray TAG e-mail: chr### [at] tag povray org
TAG web site: http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |