Carapace

Variable Number of Arguments

A function or method can have a variable number of arguments by ending the argument list with ... (ellipsis). Any arguments defined before the ellipsis are checked as normal. Any remaining arguments are collected into the List called _args.

For example, the following function takes an integer argument followed by any number of other arguments.


    (defun NIL varargs ( (x Integer) ...)

        (print x)

        (print _args)

    )
When run as follows

    (varargs 1 2 3 "four")
it prints the following

    1
    (2 3 "four")


Contents Index Current topic: objects Related topics: functions