Leo80s <nomail@nomail> wrote:
> I can't understand the way I could specify the value returned by a function
> (or a macro?!)...isn't there something similar a return statement?!?!
The return value of the function is directly the evaluated expression
inside it. You don't have to "return" it explicitly.
If you write:
#declare Func = function(A) { A*A };
then the return value of Func will be its parameter squared.
With macros things get slightly more complicated. If you have just
a simple mathematical expression as the body of the macro, that serves
as its "return value". For example:
#macro Func(A)
A*A
#end
If the macro contains control flow commands, you have to use a small
trick to put a "return value". It works for example like this:
#macro Func(A)
#if(A < 0)
#local Result = -A;
#else
#local Result = A;
#end
A
#end
The value of the last line of this macro is what is ultimately used as
the "substitution" of the macro call, which is practice is its "return
value".
--
- Warp
Post a reply to this message
|