;;;; expand-full.scm ;;;; Kon Lovett, Apr '09 ;;; (module expand-full (;export expand* pretty-print-expand* ppexpand*) (import scheme chicken (only csi toplevel-command) (only extras pretty-print) (only srfi-1 map!)) (require-library extras srfi-1) ;;; ;; (define (expand* form #!optional se) (let expd ((form form)) (let ((form* (cond ((list? form) (let ((form* (expand form se))) (if (not (list? form*)) form* (map! expd form*) ) ) ) ((pair? form) (cons (expd (car form)) (expd (cdr form))) ) (else (expand form se) ) ) ) ) (if (equal? form form*) form (expd form*) ) ) ) ) ;; (define (pretty-print-expand* form #!optional se) (pretty-print (strip-syntax (expand* form se))) (void) ) (define ppexpand* pretty-print-expand*) ;;; (when (feature? csi:) (toplevel-command 'x* (lambda () (ppexpand* (read))) ",x* EXP Pretty print fully expanded expression EXP") ) ) ;module expand-full