May 19th 2004 #
random, May 19th 2004
When working on running SBCL with internal packages locked I realized a problem:
(in-package :locked) (defmacro foo () 'foo) (defmacro with-foo! (&body body) `(macrolet ((foo () 'foo!)) ,@body)) (in-package :other) (with-foo! ...)
Gives a compile-time error that no amount of WITH-PACKAGE-LOCKS-IGNORED is going to cure (unless you wrap the compile-file with it). Why?
Because package-locks are mostly checked at compile-time, and the expansion of WITH-FOO! happens while in package OTHER. Duh. Options:
- Make package lock violations detected at compile-time just generate the code to signal the error when the code-path is taken.
- Have a way to tell the compiler to ignore the lock in this special case. (Needless to say that would be done in the context of WITH-FOO! definition.)
Christophe Rhodes to the rescue! The work he's been doing on selectively muffling compiler-notes, style-warnings, warnings, and whatnot via declarations turns out unexpectedly synergetic. I'll skip the details (check #lisp logs if you're curious), but YAY! for protocols, and WOOT! for hooks into compiler, even though it may be that I end up using both #1 and #2.