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


10.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

There is an alternate syntax that can only be used in an expression-as-statement context. 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