POV-Ray : Newsgroups : povray.general : #declare : Re: #declare Server Time
5 Aug 2024 08:26:58 EDT (-0400)
  Re: #declare  
From: Christopher James Huff
Date: 18 Oct 2002 10:35:44
Message: <chrishuff-88DD56.10304618102002@netplex.aussie.org>
In article <Xns### [at] 204213191226>,
 "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:

> Hello,
> #declare aaa = ... ;
> is probably most common exprssion in POV while using it as srcipt language, 
> why the idea introduced in MegaPov ( to use $aaa=...; ) was droped / not 
> included into officila Pov 3.5 ?

1: It's ugly.
2: It's harder to read.
3: It doesn't fit in with the rest of the syntax.
4: It didn't work right. I don't know what exactly the problems were (I 
never used the patch), but there were problems with it.

I don't like the current syntax either, though...take this code for 
example:

#declare myCounter = 0;
#while(myCounter < 10)
    Code
    Code
    Code
    Code
    ...
    #declare myCountr = myCounter + 1;
#end

That's an infinite loop from a simple typo, because POV doesn't know the 
difference between modifying a variable and making a new one.

I made a patch that allowed this:
#declare myCounter = 0;
#while(myCounter < 10)
    #set myCountr = myCounter + 1;
#end

#set will modify a variable, but it will give an error if it doesn't 
already exist, something like "attempt to set nonexistant variable". It 
is also less typing, and makes less code to modify if you decide to put 
things in a macro...it works with local variables just fine, so you have 
fewer #declares to turn into #locals.

This was designed to fit in with the current syntax, though. I'd rather 
redesign the language and use something more like:

def myCounter = 0;
while(myCounter < 10) {
    myCounter += 1;
}

-- 
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.