POV-Ray : Newsgroups : povray.binaries.images : #let keyword(was: Previews of Ice Planet...) : #let keyword(was: Previews of Ice Planet...) Server Time
2 Sep 2024 00:14:37 EDT (-0400)
  #let keyword(was: Previews of Ice Planet...)  
From: Chris Huff
Date: 30 Aug 2000 11:54:53
Message: <chrishuff-37B8CF.10562630082000@news.povray.org>
In article <chrishuff-AF5968.09493830082000@news.povray.org>, Chris 
Huff <chr### [at] maccom> wrote:

> Well, I guess I was wrong!
> BTW, I think I just figured out how to implement it, just have to 
> compile and test it...

I just finished implementing the #set keyword. It works perfectly: it 
modifies the most recently created version of a variable, but if given a 
variable that doesn't yet exist, it produces an error. It works properly 
with local variables, modifying the "most local" one.

Basically, instead of:
#declare J=0;
#while(J<10)
    #declare J=J+1;
#end

you would use:
#declare J=0;
#while(J<10)
    #set J=J+1;
#end

One place this is useful is if you make a typing mistake, like this:
#declare MyCounter=0;
#while(MyCounter<10)
    #declare MyCountr = MyCounter+1;
#end
This would normally cause an infinite loop, and may take a while to 
track down, especially in complex scenes and with typos that "look 
right" at a glance. If #set was used, it would cause an error ("#set 
cannot assign to uninitialized identifier MyCountr.") at that line, 
pointing you directly at the problem.

Another thing is that it makes it more visually clear where variables 
are *created*, and where they are only *changed*.
And it is less typing. ;-)

I will post the code for this patch in these newsgroups soon.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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