POV-Ray : Newsgroups : povray.general : A macro that drops a vector-- what's the syntax again? : Re: Has this bug been reported? Server Time
1 Aug 2024 16:28:25 EDT (-0400)
  Re: Has this bug been reported?  
From: John VanSickle
Date: 12 Nov 2005 11:15:01
Message: <43761505$1@news.povray.org>
Thorsten Froehlich wrote:

> John VanSickle wrote:
> 
>> Greg M. Johnson wrote:
>>
>>> I cannot get the following code to work:
>>>
>>> //-----------------------------
>>> #macro sign(a)
>>> #if (a<0)
>>>         (-a)
>>> #else
>>>         (a)
>>> #end
>>> #end
>>
>>
>> I've noticed that this way of using macros to express things leads to 
>> parse errors.  There is a work-around (which has already been posted), 
>> but the docs give no reason for this construction to fail.
> 
> 
> Well, they do, but I agree it could be a lot clearer.  In "Are POV-Ray 
> Macros a Function or a Macro?" it explains it:
> 
> "When the body of a macro consists of statements that create an entire 
> item such as an object, texture, etc. then the macro acts like a 
> function which returns a single value."
> 
> The "statements that create an entire item" is the important part here. 
> What the macro above is are *two* statements that create *two* items.  
> Basically, the word "item" means what is best explained as "evereything 
> you could also assign to a single #declared variable".
> 
>> Is this behavior deemed worthy of correction?
> 
> 
> It is correct, and it is also possible to obey the "one statement" rule! 
> :-)  It just requires slightly different syntax:
> 
> #macro sign(a)
> (
> #if (a<0)
>         -a
> #else
>         a
> #end
> );
> #end
> 
> is perfectly legal!

Okay.  I was already using the work-around.

Regards,
John


Post a reply to this message

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