POV-Ray : Newsgroups : povray.general : Let me get this straight--a local variable can't have the same name as a ma= : Re: Let me get this straight--a local variable can't have the same name as = Server Time
30 Jul 2024 18:10:42 EDT (-0400)
  Re: Let me get this straight--a local variable can't have the same name as =  
From: Reactor
Date: 30 Aug 2008 22:35:01
Message: <web.48ba0233eb38098157e7c8b50@news.povray.org>
"Cousin Ricky" <ric### [at] yahoocom> wrote:

> This is such a major breach of structured programming principles that I'm sure
> that someone else has complained about this, somewhere in the newsgroup
> archives.  Just add me to the petition.  I trust that version 4.0 will get rid
> *all* scope leakage--including the inability to redefine an identifier as a
> different type.


While it can be a hassle, the documentation states that all macros are permanent
and global in scope.  If the variable A had shared a name with a #declared
variable, the local one would have behaved as expected (but there would be no
way to reference the global of the same name while the local identifier
exists).  As for the last part, of redefining an identifier as a different
type, Povray already permits that except for macros, because they are
permanent.  To do it for a macro, you must use the #undef directive.


Scope control is something I briefly wrote about for a tentative list of changes
for SDL in 4.0.  There is (as always) more than one way to address this.  What
would you recommend?  On my list I put down the introduction of namespaces and
some new directives for scope control:

<snip>
I wouldn't mind seeing new directives, such as #global for global variables
(instead of declare) and #const for properties that can be referenced but not
set (i.e. using #const with your camera{} block would allow macros to retrieve
the camera settings, but not change them).  #local should be truly local to its
block, and not freely accessible within a file unless it is defined outside of
other code.

#private might also be useful from properties that you want to keep hidden from
outside of the object, and maybe a #static storage class for some variables or
for preventing macros internal to another macro from being called externally.
</snip>

Even though pov 4 is probably a bit beyond the horizon, I have been slowly
building lists of things that have come up in discussion or things that I've
run into.  I'd appreciate it if you had any specific recommendations for
changes.

-Reactor


Post a reply to this message

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