|
|
On 04/05/2018 12:21 PM, clipka wrote:
> #declare MySeed = seed(4711);
> #macro MyRand(Min,Max)
> // compute stuff
> #local Rand = rand(MySeed);
> #local Result = Min + (Max-Min)*Rand;
> // "return" the computed value
> Result
> #end
>
I wrap the return value in parenthesis. The intent is a little clearer
in the macro def and may avoid usage problems.
// "return" the computed value
(Result)
I know clipka, legally this is not required, because Result is a single
number. But I tend to do
#local V=<1,2,3>;
// "return" the computed value
(Result+V)
where it is morally (debuggingly?) required.
sven, this is because when you use it, think of the expansion.
#local R = MyRand(low, high) * 2;
which without parens, is
#local R = Result + V * 2
which of course evaluates as
#local R = Result + (V * 2)
which is not at all what you want. With the parens, you get
#local R = (Result + V) * 2
which is the intent of your usage.
--
dik
Rendered 328976 of 330000 (99%)
Post a reply to this message
|
|