|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |