;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id$
-;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; KMRCL users are granted the rights to distribute and use this software
(let ((it ,val)) ,@(cdr cl1))
(acond2 ,@(cdr clauses)))))))
-(defmacro mac (expr)
-"Expand a macro"
- `(pprint (macroexpand-1 ',expr)))
+(defmacro mac (form &key (stream *standard-output*) (full nil) (width 80)
+ (downcase t)
+ &environment env)
+ (multiple-value-bind (expanded expanded-p)
+ (funcall (if full #'macroexpand #'macroexpand-1) form env)
+ (write expanded
+ :stream stream
+ :pretty t
+ :right-margin width
+ :case (if downcase :downcase :upcase)
+ :length nil
+ :level nil
+ :circle nil
+ :gensym nil)
+ (fresh-line stream)
+ expanded-p))
(defmacro print-form-and-results (form)
- `(format t "~&~A --> ~S~%" (write-to-string ',form) ,form))
-
+ (let ((r (gensym "RES-")))
+ `(let ((r ,form))
+ (format t "~&~A --> ~S~%" ',form r)
+ r)))
;;; Loop macros
,@body))
(defmacro for ((var start stop) &body body)
- (let ((gstop (gensym)))
+ (let ((gstop (gensym "STOP-")))
`(do ((,var ,start (1+ ,var))
(,gstop ,stop))
((> ,var ,gstop))
,@body)))
(defmacro with-each-stream-line ((var stream) &body body)
- (let ((eof (gensym))
- (eof-value (gensym))
- (strm (gensym)))
+ (let ((eof (gensym "EOF-"))
+ (eof-value (gensym "EOF-VALUE-"))
+ (strm (gensym "STREAM-")))
`(let ((,strm ,stream)
(,eof ',eof-value))
(do ((,var (read-line ,strm nil ,eof) (read-line ,strm nil ,eof)))