[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

compiler-let, again



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
-------