[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
compiler-let, again
- To: cl-compiler@sail.stanford.edu
- Subject: compiler-let, again
- From: sandra%defun@cs.utah.edu (Sandra J Loosemore)
- Date: Tue, 27 Sep 88 12:46:46 MDT
- Cc: kmp@stony-brook.scrc.symbolics.com
Here is an alternate way to handle Pitman's COMPILER-LET example using
MACROLET. It is somewhat cleaner than the solution Pitman suggested
because it doesn't need to pass environments around or do explicit
macroexpansion.
(defmacro local-type-declare (declarations &body forms)
(local-type-declare-aux declarations forms))
(eval-when (eval compile load)
(defun local-type-declare-aux (declarations forms)
`(macrolet ((typed-var (var)
(let ((type (assoc var ',declarations)))
(if type `(the ,(cadr type) ,var) var)))
(local-type-declare (new-declarations &body new-forms)
(local-type-declare-aux
(append new-declarations ',declarations)
new-forms)))
,@forms)))
I could have avoided the EVAL-WHEN and the helper function by using
LABELS instead.
-Sandra
-------