7.2. Function Arguments

When a function is called, the arguments in the call are mapped to the arguments specified in the function definition on a one-to-one basis. The Gamma engine evaluates the arguments and maps the results of those evaluations to each function argument name. Since Gamma is abstractly typed, there is no need to specify a data type in the function definition. If a particular data type is required within the function, then the function body can check for the type using the type predicate, type-p.

7.2.1. Variable number of arguments

It is possible to create a function that takes a variable number of arguments. The last argument in a function's argument list may be made to act as a "catch-all" or vararg argument which collects all remaining arguments provided in the function call as a list. For example,

function f (x, y...)

creates a function with 2 mandatory arguments, the second of which can have one or more values. If this function is called as f (1,2), then x will have the value 1, and y will have the value (2), that is, a list containing one element whose value is 2. If this function is called as f (1,2,3,4,5), then x will be 1, and y will be (2 3 4 5), a list of four elements. If this function is called as f(1), then an error would occur because y is not optional.