POV-Ray : Newsgroups : povray.general : Did you know? : Re: Did you know? Server Time
2 Oct 2025 20:34:35 EDT (-0400)
  Re: Did you know?  
From: Cousin Ricky
Date: 29 Sep 2025 13:37:02
Message: <68dac3be$1@news.povray.org>
On 2025-09-25 18:45 (-4), Leroy wrote:
> Variables can act as any type.

There are some exceptions:
 - Macro names cannot be reused as another type without being #undef'd.
 - Function names cannot be reused--even as another function--without
   being #undef'd.
 - Function formal parameters cannot take the name of any existing
   identifier.

Notwithstanding the above, macro formal parameters can always reuse any
name.

Irritatingly, these apply even to local identifiers, meaning that truly
modular programming is impossible in POV-Ray.  If you write a public
include file, you must make sure that your local variables do not
conflict with any macro names that any other POVer might ever use.  If
you write a function that has any formal parameters other than u, v, x,
y, or z, you must choose parameter names that do not conflict with any
identifier of any type that any other POVer might ever use.  And if
you're just creating a scene file, you always run the risk of your
script bombing out because of conflicts with the innards of include
files that, by rights, you shouldn't have to know about.

The fact that macro formal parameters can reuse macro and function names
shows that this scope leakage is not logically inevitable.  It may take
a lot of work on the parser to fix this design flaw, but I think it
should be a priority.


Post a reply to this message

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