type: special form (fsubr) location: built-in source file: xlcont.c Common LISP compatible: yes supported on: all machines
(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
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 <symbol>s of the <functions> and then sequentially execute the <expr>'s. The value of the last <expr> evaluated is returned. When the FLET is finished execution, the <symbol>'s that were defined will no longer exist.
(flet ( (fozz (x) (+ x x) )) ; an FLET with FOZZ local func. (fozz 2)) ; returns 4 ; FOZZ no longer exists (fozz 2) ; error: unbound function - FOZZ ; an empty flet (flet () (print 'a)) ; prints A
NOTE: FLET does not allow recursive definitions of functions. The LABEL special form does allow this.