http://t3x.org/mcl/grind.html   (light|dark)

MICRO COMMON LISP

Grinding and Macro Expansion

This is a REPL session with the MICRO COMMON LISP grinder (pretty-printer). It also demonstrates macro expansion.

MICRO COMMON LISP 03
5116 NODES

* (load "src/grind")
T

* (gc)
2558                  ; the grinder uses half of the memory!

* (load "src/macexp") ; load MACROEXPAND
T

* (defparameter *prog*
    '(do ((a nil (cons 'x a))
          (b nil (cons a b))
          (c '(1 2 3 4) (cdr c)))
         ((null c) b)))
*PROG*

* (grind *prog*)
(DO ((A NIL (CONS (QUOTE X) A))
     (B NIL (CONS A B))
     (C '(1 2 3 4) (CDR C)))
  ((NULL C)
   B))
T

* (macroexpand-1 *prog*)
(LABELS ((#32 (A B C) (COND ((NULL C) B) (T (#32 (CONS (QUOTE X) A)
(CONS A B) (CDR C)))))) (#32 NIL NIL (QUOTE (1 2 3 4))))

* (grind (macroexpand-1 *prog*))
(LABELS
  ((#32 (A B C)
     (COND ((NULL C)
             B)
           (T
             (#32
               (CONS (QUOTE X) A)
               (CONS A B)
               (CDR C))))))
  (#32
    NIL
    NIL
    '(1 2 3 4)))
T

* (macroexpand *prog*)
((LAMBDA (#32) (FSETQ #32 (LAMBDA (A B C) (IF (NULL C) (PROGN B) (PROGN (#32
(CONS (QUOTE X) A) (CONS A B) (CDR C)))))) (#32 NIL NIL (QUOTE (1 2 3 4))))
NIL)

* (grind (macroexpand *prog*))
((LAMBDA (#33)
   (FSETQ #33 
     (LAMBDA (A B C)
       (IF (NULL C)
           (PROGN B)
           (PROGN
             (#33
               (CONS (QUOTE X) A)
               (CONS A B)
               (CDR C))))))
   (#33
     NIL
     NIL
     '(1 2 3 4)))
 NIL)
T

*

contact | privacy