POV-Ray : Newsgroups : povray.newusers : Ignorance rules! : Re: Ignorance rules! Server Time
23 Jun 2021 05:10:54 EDT (-0400)
  Re: Ignorance rules!  
From: Cousin Ricky
Date: 23 Jun 2020 12:28:19
Message: <5ef22da3$1@news.povray.org>
On 2020-06-23 4:42 AM (-4), jr wrote:
> Cousin Ricky <ric### [at] yahoocom> wrote:
>> ...
>>     - Once *any* identifier is declared, it cannot be reused as a macro
>>       name.
> 
> maybe I misunderstand.  the following works on alpha.10064268.unofficial
> 
> -----<snip>-----
> #version 3.8;
> 
> global_settings {assumed_gamma 1}
> 
> #declare A = 0;
> 
> #undef A
> 
> #macro A(b_)
>    b_
> #end
> 
> #declare B = A(1);
> 
> #debug concat("B = ",str(B,0,0),"\n")
> -----<snip>-----

Of course you can reuse any identifier after you undefine it.  But why 
should you have to go through such nonsense?

> (if you remove the '#undef', ie try to create macro with same name while the
> identifier still _is_in_use_, error "expected undeclared identifier" occurs.
> which is as it should be, aiui)

No. It. Shouldn't.

What if the macro was defined in an include file written by someone 
else? If the user declares A, they obviously have no need for macro A, 
so why should they have to worry about whether a macro by that name 
already exists?

But this is less serious an issue; the fact remains that if you declare 
a *local* variable with the same name as a macro, the scene will not 
parse.  This means that anyone who writes a macro must make sure they do 
not use local variables with the same name as a macro in any other 
include file--even include files written by total strangers.  The same 
goes for function formal parameters.

This TOTALLY 100% defeats the purpose of local variables and formal 
parameters!  In order to write a robust POV include file, you must 
essentially read the mind of every POVer on the planet.

This is why I complain about scope leakage.  As far as I'm concerned, 
the only acceptable level of scope leakage is ZERO.


Post a reply to this message

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