21st Century Smalltalk

April 16, 2007

Lisp Update – “&rest” Parameter Added

Filed under: Lisp — pfisk @ 6:37 pm

The Lisp interpreter in Vst/Flash can now accept the “&rest” parameter in function definitions. This allows the definition of functions which can accept a variable number of arguments.

Define a function:

(defun foo(a b &rest c)
  (@println a)
  (@println b)
  (@println c)
)

Call it with 2 or more arguments:

(foo 'one 'two 'three 'four 'five)

Transcript window output:

one
two
(three four five)

Other special parameters such as “&optional” and “&key” will be added when time permits.

Blog at WordPress.com.