POV-Ray : Newsgroups : povray.advanced-users : Macro and parameters : Re: Macro and parameters Server Time
2 Dec 2025 20:39:11 EST (-0500)
  Re: Macro and parameters  
From: Cousin Ricky
Date: 28 Nov 2025 20:05:46
Message: <692a46ea$1@news.povray.org>
On 2025-11-28 12:07 (-4), kurtz le pirate wrote:
> 
> I just spent a long, long time debugging my code.
> 
> For example, this macro :
> 
> [snip]
> 
> At first glance, nothing special, but there is a problem, a big problem,
> that I hadn't noticed :(

I think I see where this is going.

> Can you see it too? Well done.
> 
> 
> I also program in C, so perhaps that's where the confusion comes from.

Now I'm sure of it!

> But I'll explain it anyway.
> 
> 
> The annoying part is this one :
> 
>     #if ( k > n-k )
>       #local k = n - k;
>     #end
> 
> ... and so, the "#local k =" led me to believe I was using a local
> variable. Well, not at all. "k" represents the variable passed as a
> parameter and its value is modified in the part that called this macro.

Saw it coming!  This feature (not a bug!) has zapped some veterans,
including BE, Ive, and the author of colors.inc::CH2RGB().

The particulars are explained here:

https://wiki.povray.org/content/Reference:User_Defined_Macros#Returning_Values_Via_Parameters


Post a reply to this message

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