Next: , Previous: , Up: Functions   [Contents][Index]


17.12.4 Calling Functions

To call a function, write its name followed by the arguments in parentheses. Examples:

foo (1,2,3)
bar ()

If the function takes no arguments then it is not necessary to write the empty list of arguments. Therefore the following two calls are equivalent:

bar ()
bar

If the closure of function that takes no arguments is needed, the call can be avoided by putting the variable immediately inside parenthesis, like this:

(poke) (foo)
#<closure>

There is an alternate syntax that can be used in both expressions and expression-statements. This alternate syntax is:

function_name :arg1 val1

where arg1 is the name of an argument and val1 the value to pass for that argument. This is useful when using functions as commands in the REPL:

(poke) dump :from 12#B :size 16#B :ascii 0

Note that the named arguments can appear in any order. The following two calls are equivalent:

dump :from 12#B :size 16#B
dump :size 16#B :from 12#B

If this alternate syntax for function calls is to be used in an expression, it is necessary to surround it with parenthesis:

2 + (gcd :a 1024 :b 8)