common-lisp Functions Function without Parameters


Example

Global named functions are defined with DEFUN.

(defun foobar ()
  "Optional documentation string. Can contain line breaks.

Must be at the beginning of the function body. Some will format the
docstring so that lines are indented to match the first line, although
the built-in DESCRIBE-function will print it badly indented that way.

Ensure no line starts with an opening parenthesis by escaping them
\(like this), otherwise your editor may have problems identifying
toplevel forms."
  (format t "No parameters.~%"))

(foobar)
; No parameters.
;=> NIL

(describe #'foobar) ; The output is implementation dependant.
; #<FUNCTION FOOBAR>
;   [compiled function]
;
; Lambda-list: ()
; Derived type: (FUNCTION NIL (VALUES NULL &OPTIONAL))
; Documentation:
;   Optional documentation string. Can contain line breaks.
;   
;   Must be at the beginning of the function body. Some will format the
;   docstring so that lines are indented to match the first line, although
;   the built-in DESCRIBE-function will print it badly indented that way.
; Source file: /tmp/fileInaZ1P
;=> No values

The function body may contain any number of forms. The values from the last form will be returned from the function.