Attached is a partial fix for the bug regarding top-level form
processing at the REPL. It fixes SBCL's behaviour for cases such as
(locally (defmacro foo (x) `(print ,x)) (foo 1))
and the like (which has always worked in a compiled file, but has been
failing at the REPL, because LOCALLY had been passed to COMPILE inside a
LAMBDA, which broke the top-level-form one-at-a-time semantics.
The fix is partial in several ways. Firstly, MACROLET and
SYMBOL-MACROLET have the same property of preserving toplevelness of
their body forms (e.g.
(symbol-macrolet () (defmacro foo (x) `(print ,x)) (foo 1))
should likewise work); this patch does not address this issue, though if
the approach in this patch seems correct it shouldn't be too hard to
Secondly, on the subject of the approach in this patch, I've had to
expose more of the compiler's internals to EVAL; in some ways that's not
too surprising, but in others it's fairly ugly.
Thirdly and perhaps most worryingly, this patch causes regressions in
some of the tests [involving (assert (not (ignore-errors ...)))]; I
can't for the life of me see why :-( The relative paucity of failing
tests is probably due to the non-implementation of MACROLET and
toplevelness, as the test-files often have the idiom of
(macrolet ((foo ...))
(locally (declare (optimize (safety 3)))
and our present implementation of macrolet hands things off to
COMPILE... any ideas? Other comments?
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)