|
![](/i/fill.gif) |
Ahh...I think I see now.
So essentially a macro in pov-sdl, when called, returns a code
block/whatever its contents happen to be?
Am I correct to believe they can be written to represent so-called
"high-order" functions, which will accept a functions as a variable, and can
return other functions as a result?
If this is the case, it will now be much easier to work with macros, as
before I was treating them as low-level functions.
I guess that debug/concat feature might help in determining this sort of
thing in the future, huh? hehehe :-)
Thanks,
Ian
"Mike Williams" <nos### [at] econym demon co uk> wrote in message
news:gc5### [at] econym demon co uk...
> Wasn't it [GDS|Entropy] who wrote:
>>Hello,
>>
>>A little stuck here... evidently povray does not support any type of
>>Return() function, and I am not familiar enough with sdl yet to figure
>>this
>>out any other way.
>>This little macro does what it says, but not in this form.
>>
>>#macro isEvenOrOdd(integer)
>> #if(mod(integer,2) = 0)
>> #local isEven = 1;
>> #else
>> #local isOdd = 1;
>> #end
>>#end
> >
>>There HAS to be some way to pass variables from a macro...right? :-\
>
> You're confusing the concept of MACRO with the concept of FUNCTION.
>
> The entire contents of a macro are "returned", so you can write:
>
>
> #macro isEven(integer)
> #if(mod(integer,2) = 0)
> #local even = 1;
> #else
> #local even = 0;
> #end
> (even)
> #end
>
> #if (isEven(3))
> #debug "3 is even\n"
> #else
> #debug "3 is odd\n"
> #end
>
>
> Or
> #macro isOdd(integer)
> (mod(integer,2))
> #end
>
> #if (isOdd(3))
> #debug "3 is odd\n"
> #else
> #debug "3 is even\n"
> #end
>
>
> Don't get confused into thinking that those macros get evaluated and then
> return integer values. They "return" chunks of SDL code like
> #if(mod(3,2) = 0) #local even=1; #else #local even = 0; #end (even)
> And what happens is that
> #if (isEven(3))
> effectively becomes
> #if (#if(mod(3,2) = 0) #local even=1; #else #local even = 0; #end
> (even))
> and THEN gets evaluated.
>
> --
> Mike Williams
> Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |