[postmodern-devel] with-connection is strange...

Hi there, The macro with-connection doesn't seem to work as I would expect. It seems two macros were merged... I am curious as to why the following definition is used: (defmacro with-connection (spec &body body) "Like with-connection, but evaluate the specification list." `(let ((*database* (apply #'connect ,spec))) (unwind-protect (progn ,@body) (disconnect *database*)))) Note the documentation above. I think a more standard "with-" macro doesn't evaluate the spec (like below). (defmacro with-connection (spec &body body) "Like with-connection, but evaluate the specification list." `(let ((*database* (connect ,@spec))) (unwind-protect (progn ,@body) (disconnect *database*)))) What's the reasoning here? -Luke

It indeed used to not evaluate it's spec (which explains the silly comment, there was also a with-connection* which did), but now it does, since this makes using it much easier -- you'll usually want to pass such a spec around as a list, and it's clumsy to have to unpack it every time you use the macro: (with-connection ((car spec) (cadr spec) (caddr spec)) ...) So in version 1.1 (I think) I dropped the old non-evaluating version, and made only this one available. I'll change the docstring. Best, Marijn
participants (2)
-
Lucas Hope
-
Marijn Haverbeke