POV-Ray : Newsgroups : povray.bugreports : Macro parameters with the same name : Re: Macro parameters with the same name Server Time
8 Nov 2024 23:02:15 EST (-0500)
  Re: Macro parameters with the same name  
From: William F Pokorny
Date: 23 May 2023 08:37:27
Message: <646cb387$1@news.povray.org>
On 5/23/23 00:50, Cousin Ricky wrote:
> As it turns out, POV-Ray appears to choose the latter instance.
> Arbitrarily.  It could have been the other way around.  It could have
> been random.  Maybe it*is*  random, and I just haven't done enough test
> cases.

In a look at three other languages...

C/C++ (gcc/g++ 11.3.0)considers the duplicate parameter names/ids to be 
an error. As does python3 (3.10.6).

The scripting languages tcl (8.6) allows the duplication and it appears 
the first setting of the repeated name/id always wins.

In POV-Ray SDL I think the last setting of the parameter will always win 
because POV-Ray maintains symbol tables (key -> value hash tables) so 
the last time the symbol is set in the current scope is what the value 
is thereafter.

If allowing duplicate parameters, I think POV-Ray's last value wins 
method more intuitive as inside macros / functions we can always update 
the local variable(a). These within code body/block overrides are always 
the last setting wins so it sort of makes sense the last time a 
duplicated parameter name is set should win out too.

I lean toward the duplication of parameter names being an error. I think 
duplicates are far more likely to cause confusion than help.

Bill P.

(a) excepting where languages support constant parameters/variables and 
the feature used.


Post a reply to this message

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