XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

flet


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

Syntax

(flet ([function ... ]) expr ... )
function - a function definition binding which is of the form:
(symbol arg-list body)
symbol - the symbol specifying the function name
arg-list - the argument list for the function
body - the body of the function
expr - an expression
returns - the value of the last expression

Description

The 'flet' special form is basically a local block construct that allows local 'function' definitions followed by a block of code to evaluate. The first form after the 'flet' is the 'binding' form. It contains a series of 'functions'. The 'flet' form will go through and define the 'symbols' of the 'functions' and then sequentially execute the 'exprs'. The value of the last 'expr' evaluated is returned. When the 'flet' is finished execution, the 'symbols' that were defined will no longer exist.

Examples

(flet ((fuzz (x) (+ x x)))  ; an FLET with FUZZ local function
  (fuzz 2))                 ; returns 4
                            ; FUZZ no longer exists

(fuzz 2)                    ; error: unbound function - FUZZ

                            ; an empty flet
(flet () (print 'a))        ; prints A

Note: 'flet' does not allow recursive definitions of functions. The label special form does allow this.

See the flet special form in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next