XLISP function

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# function

Type: | - | special form (fsubr)
Source: | - | xlcont.c

## Syntax

(function expr)
  expr - an expression that evaluates to a function
  returns - the functional interpretation

## Description

The 'function' special form returns the function definition of the 'expr'. Execution of the 'expr' form does not occur. 'function' will operate on functions, special forms, lambda-expressions and macros.

## Examples

    (function car)              ; returns #<Subr-CAR: #23ac4>
    (function quote)            ; returns #<FSubr-QUOTE: #23d1c>
    #'quote                     ; returns #<FSubr-QUOTE: #23d1c>
    (function 'cdr)             ; error: not a function

    (defun foo (x) (+ x x))     ; define FOO function
    (function foo)              ; returns #<Closure-FOO: #2cfb6>

    (defmacro bar (x) (+ x x))  ; define FOOMAC macro
    (function bar)              ; returns #<Closure-BAR: #2ceee>

    (setq my 99)                ; define a variable MY
    (function my)               ; error: unbound function

    (defun my (x) (print x))    ; define a function MY
    (function my)               ; returns #<Closure-MY: #2cdd6>

Read macro: XLISP supports the normal Lisp read macro of a hash and quote [#'] as a short-hand method of writing the 'function' special form.

See the function special form in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference