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

macrolet


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

Syntax

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

Description

The 'macrolet' special form is basically a local block construct that allows local 'macro' definitions followed by a block of code to evaluate. The first form after the macrolet is the 'binding' form. It contains a series of 'macros'. The 'macrolet' form will sequentially execute the 'exprs' after defining the 'macros'. The value of the last 'expr' evaluated is returned. When the 'macrolet' is finished execution, the 'symbols' that were defined will no longer exist.

Examples

(macrolet ((pls (n1 n2) `(+ ,n1 ,n2)))  ; a MACROLET form including a PLS macro
  (pls 4 5))                            ; returns 9

                                        ; the PLS macro no longer exists
(pls 4 5)                               ; error: unbound function - PLS

                                        ; an empty MACROLET
(macrolet () (print 'a))                ; prints A

See the macrolet special form in the XLISP 2.0 manual.

  Back to Top


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