POV-Ray : Newsgroups : povray.general : #declare : Re: #declare Server Time
5 Aug 2024 14:19:28 EDT (-0400)
  Re: #declare  
From: Christopher James Huff
Date: 20 Oct 2002 11:10:26
Message: <3db2c762@news.povray.org>
"hughes, b." <omn### [at] charternet> wrote in message
news:3db1fdaf$1@news.povray.org...
> Would it be conceivable that a future POV-Ray could tag any and all
> user-defined identifiers, regardless of case, as a non-keyword? It's not
> always compulsory to use upper case letters so it can seem okay. In fact,
> people have often complained they couldn't use a number as the first
> character either.

There are two reasons not to allow keywords as identifiers:
1: Ambiguity. In some cases, it could be impossible or difficult for the
parser to tell a keyword from an identifier of the same name. For example:
def while = 0;
while(while < 10)
{
    while++;
}
Most parsers will try to start another while loop nested in the first one.
Catching this case complicates the parser while adding no functionality.
Another example:

function while(fooBar) {...do something...}
while(1);

Now, write a parser that handles *that* properly. There is no way to tell
the difference between a function call and an infinite loop unless you
change the loop syntax.

You could add a mandatory first character, like "$", but that doesn't solve
anything...it makes things less readable by scattering meaningless symbols
everywhere, and makes every name longer by one useless character.
If you really want variables like this so you can use keywords as names,
just put a "_" in front of the names, like "_while" or "_declare". Does the
same thing, without annoying everyone else. Just don't ask anyone else to
put up with your code...

2: Readability. It is far better if the word used for a keyword is *always*
used for a keyword.


Post a reply to this message

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