[cmucl-imp] Lexical environment and compiler macro functions.
Mark Cox
markcox80 at gmail.com
Sun Mar 15 06:16:36 UTC 2015
G'day,
CMUCL does not shadow the compiler macro function present in the
global environment when introducing a function with the same name in
the current lexical environment. This is demonstrated with the
following example:
(defun square (x)
(expt x 2))
(define-compiler-macro square (&whole form arg)
(declare (ignore arg))
form)
(defun test ()
(flet ((square (arg)
(declare (ignore arg))
(write "SQUARE!")))
(macrolet ((my-square (arg &environment env)
(if (compiler-macro-function 'square env)
`(function square)
nil)))
(my-square 1))))
(test)
=> #<Function (FLET SQUARE TEST) {48704B89}>
Thanks
Mark
More information about the cmucl-imp
mailing list