suve

awful: function: call

declaration

mixed :call ( string $NAME , mixed &ARG , … )

summary

Calls a function. The first argument is expected to be a string containing the function name (the leading : colon can be omitted). The rest of the parameters are treated as arguments for the function to be called and forwarded to it. (Variable references will work inside the function called!) Returns the value returned by invoked function.

Can be used to make dynamic function calls, or to call a function defined after the calling point. If function is not found, simply returns NIL.

example

# :n! is undefined here. We have to use :call to call it.
:writeln s'10! = ' :call s':n!' i10

# :n! is declared here
!fun :n! $NUM
    :set &X i1
    !while $NUM
        :mul &X $NUM
        :sub &NUM i1
    !done
    :return $X
!nuf

# :n! has been defined. We can now call it explicitly.
:writeln s'10! = ' :n! i10

wikipage modified on 2014/0601/2316