On Sat, Jun 09, 2007 at 02:34:27PM -0400, Guillaume Cartier wrote :
(foo) -> no backtrace available (eval '(foo)) -> it works! Marc, can you tell us if this trick of wrapping eval the macro is clean and why it works?
I guess that it happens so because the macro expansion and the code evaluation happen at two different stages.
(define-macro(foo) (begin (pp "macro") '(pp 42)))
(pp 41) (foo) (pp 43)
It your run the following code, the sentence "macro" prints *before* the number 41, but 42 gets printed at the right place.
You have no backtrace yet because it expects a trace of the evaluation of your code, whereas it fails even before evaluating it in fact. By using eval, I guess that you delay the macro expansion at your code's evaluation time, therefore letting the backtrace happen.
By the way, for this very reason, doing (eval '(foo)) fails at mine, for when it gets evaluated, the macro has already disappeared... But having the whole code (including the macro definition) inside an eval then makes it debuggable, for the expansion is at code-evaluation time (eval '(begin (define-macro(foo) (begin (pp "macro") (car 1) '(pp 42))) (foo)))
I hope it answers your question and that Marc will nod :)
Adrien.