[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Macrolet
I am trying to use MACROLET to hide the global definition of a macro
name with my own version. I want to define a function that accepts a
form to be evaluated in the lexical environment of the MACROLET.
I know that I must have to deal with the environment argument to
macroexpand-1 but can't seem to grok it. The following never seems to
expand the form correctly.
(defun foo (form)
(macrolet ((my-macro (&rest x)
`(funcall #'+ ,@x)))
(format t "~&Form: ~a~%Expansion: ~a~&" form (macroexpand-1 form))
(eval (macroexpand-1 form))
))
=> (foo '(my-macro 1 2 3))
This should return 6 but the eval causes an undefined function error
since the expansion is never really done.
So, how do I get macroexpand-1 to recognize the lexical environment
that the my-macro macro is defined in?