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 10:12:34 EDT (-0400)
  Re: Has this bug been reported?  
From: Thorsten Froehlich
Date: 11 Nov 2005 18:12:00
Message: <43752540$1@news.povray.org>
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!

	Thorsten


Post a reply to this message

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