The general syntax for function calls is
function(arg1, arg2, … argn)
function has the syntax of an operand and is the function to be called. The args have the syntax of expressions, and are the arguments to the function. The function will often be a named value reference, but it can be any other kind of operand as well.
In the following example, the function being called is the value of the
In the following two examples, the function being called is the value of
method statement. The examples differ only in that the second example puts
parentheses around the
method statement, to make the code somewhat more
method(x) x + 1 end (99) (method(x) x + 1 end) (99)
In the following examples, the function being called is the result of another function
key-test takes a collection as an argument, and returns a predicate
function. The predicate function is then applied to the two keys. The following three
program fragments will have the same effect.
key-test(collection)(key1, key2) (key-test(collection))(key1, key2) begin let fun = key-test(collection); fun(key1, key2); end
Functions may accept keyword arguments. These are optional and order-independent. They may
also accept a variable number of
A complete description of functions, parameter lists, and function calling is given
in Chapter 6,
Dylan provides a shorthand syntax for functions that accept one argument. The
applies function to argument. This syntax is commonly used for slot
reference, to access the function slot of argument.
Order of execution aside, the following pairs of function calls are equivalent:
america.capital capital(america) window.position position(window)
Slot reference syntax can be cascaded and is left associative. Order of execution aside, the following pair of expressions are equivalent. Each returns the origin of the root-view of a window.
Dylan provides a shorthand syntax for element reference. The
sequence[i] is equivalent to
the function call
element(sequence, i). The
array[i1, i2, … in]
is equivalent to the function
aref(array, i1, i2, … in).
Order of execution aside, the following pairs of expressions are equivalent:
*all-windows* element(*all-windows*, 0) *tic-tac-toe*[1, 2] aref(*tic-tac-toe*, 1, 2)