Great, I'm going to try to modify it. Where is pp defined? I tried grepping through the scm files, but I see only calls to pp and not it's definition.
Thanks!
On Tue, Feb 10, 2009 at 5:50 AM, Marc Feeley feeley@iro.umontreal.cawrote:
On 10-Feb-09, at 3:18 AM, lowly coder wrote:
Session: ---
~/dynamic$ cat t2.scm (define-macro (assert-equal lhs rhs) (let ((g-lhs (gensym)) (g-rhs (gensym)) (e-lhs (gensym)) (e-rhs (gensym))) `(let ((,g-lhs ,lhs) (,g-rhs ,rhs) (,e-lhs ',lhs) (,e-rhs ',rhs)) (if (not (equal? ,g-lhs ,g-rhs)) (pp `(,,e-lhs = ,,g-lhs <> ,,g-rhs = ,,e-rhs))))))
(pp (lambda () (assert-equal (+ 1 2) (- 3 4))) (current-output-port))
~/dynamic$ gsi t2.scm (lambda () (let ((#:g0 (+ 1 2)) (#:g1 (- 3 4)) (#:g2 '(+ 1 2)) (#:g3 '(- 3 4))) (if (not (equal? #:g0 #:g1)) (pp `(,#:g2 ,@` (,'= ,@`(,#:g0 ,@`(,'<> ,@`(,#:g1 ,@`(,'= ,@`(,#:g3 ,@'()))))))))))) ~/dynamic$
Question: ---
Why do I have:
(pp `(,#:g2 ,@` (,'= ,@`(,#:g0 ,@`(,'<> ,@`(,#:g1 ,@`(,'= ,@`(,#:g3 ,@'())))))))))))
?
It seems prettier as:
`(,#:g2 '= ,#:g0 '<> ...)
the ,@` seems extraneous
The interpreter does a very simple form of compilation of the source code to an AST (Abstract Syntax Tree). What pp is showing you is the AST of your code. pp is not being very smart at prettifying the AST of quasiquotes. It shouldn't be too hard to add a rule such that `(X ,@`(Y...)) is turned into `(X Y...).
Marc