X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=macros.lisp;h=1239eb46b6d7d7cce32b073edc15d0d53a23efe8;hp=9b6150a470dc9597470fe8ad2ba8e303e9c3e853;hb=450dc904b65d24f9c4f19b39b330bec596ee183c;hpb=526eef1b59e071cbb4ecd35f73a14c1a3f8e32b6 diff --git a/macros.lisp b/macros.lisp index 9b6150a..1239eb4 100644 --- a/macros.lisp +++ b/macros.lisp @@ -239,3 +239,24 @@ ,@(mapcar (lambda (x) (list 'ignore-errors x)) forms))) + +(defmacro ppmx (form) + "Pretty prints the macro expansion of FORM." + `(let* ((exp1 (macroexpand-1 ',form)) + (exp (macroexpand exp1)) + (*print-circle* nil)) + (cond ((equal exp exp1) + (format t "~&Macro expansion:") + (pprint exp)) + (t (format t "~&First step of expansion:") + (pprint exp1) + (format t "~%~%Final expansion:") + (pprint exp))) + (format t "~%~%") + (values))) + +(defmacro defconst (symbol value &optional doc) + `(defconstant ,symbol (if (boundp ',symbol) + (symbol-value ',symbol) + ,value) + ,@(when doc (list doc))))