On 3 January 2012 14:17, Rupert Swarbrick <rswarbrick@...> wrote:
> Can anyone explain the following to me?
Short version: there is a compile-time side-effect from compiling the
DEFUN, which takes place before the package has been unlocked.
Gory details:
DEFUN expands into an SB-INT:NAMED-LAMBDA, compiling of which has some
side-effects we want package-locks to protected against -- namely
proclaiming the named function and removing a pre-existing
macro-definition.
This itself is wrong, since it happens in global scope, and not only
in the lexical scope of the NAMED-LAMBDA as it should.
So package locks are working right, but at an unexpected time, because
the compiler is treating DEFUN a bit too specially.
Try this for fun:
(defmacro foo () :macro)
(foo) => :MACRO
(defvar *foo* (compile nil `(lambda () (defun foo () :function))))
(foo) =| error: undefined function FOO
(funcall *foo*)
(foo) => :FUNCTION
Cheers,
-- Nikodemus
|