Dear Ken,
So obviously I'm missing the boat on special variables and defmacro. I know I could just setq *prologue* before calling cl-who (or even cruder approaches), but that seems awkward,
Awkward indeed! But if you put it into a well-separated function it's not that bad.
and I'd like to learn what's going on with special variables and macros.
Yes, that's important.
As an aside, special variables and macros aren't behaving the same in my 2 Lisp implementations (all of the above is with SBCL), so it seems that at least somebody out there thinks the same way as me: :-)
(defvar *special* 5) (defun show-special () *special*) (defmacro with-special () *special*) (show-special) (let ((*special* 10)) (show-special)) (with-special) (let ((*special* 10)) (with-special))
;; CLISP 2.43: 5, 10, 5, 10 ;; SBCL 1.0.13: 5, 10, 5, 5
Don't take my word for it, but my guess is that you've fallen right into the compiler/interpreter trap.
SBCL is a compiler-only implementation and CLISP interprets code by default.
I'll leave it as an exercise to you what exactly happens here.
If anybody could shed some light on this, and show how to most naturally use an expression as a :prologue with cl-who, it'd be much appreciated.
Not sure here either but take a look at the macro:
(defmacro with-html-output ((var &optional stream &key prologue ((:indent *indent*) *indent*)) &body body) (when (and *indent* (not (integerp *indent*))) (setq *indent* 0)) (when (eq prologue t) (setq prologue *prologue*)) `(let ((,var ,(or stream var))) ,(tree-to-commands body var prologue)))
*prologue* gets evaluated at macro expansion time, and I suppose special bindings are not in effect then. Wild guess. Wade through the spec to find out.
Or maybe someone else can point it out.
The solution here is using macros to define your own prologues.
Thanks!
Thanks for checking out Common Lisp!
Leslie