[gambit-list] rewriting a macro
Marc Feeley
feeley at iro.umontreal.ca
Sat Feb 7 08:12:49 EST 2009
On 7-Feb-09, at 5:03 AM, lowly coder wrote:
> in the following code:
>
> (define-macro (assert-equal lhs rhs)
> (let ((g-lhs (gensym))
> (g-rhs (gensym)))
> `(let ((,g-lhs ,lhs) (,g-rhs ,rhs))
> (if (not (equal? ,g-lhs ,g-rhs))
> (raise (list ',lhs '= ,g-lhs '<> ,g-rhs '= ',rhs))))))
>
> used like this:
>
> (assert-equal (+ 1 2) (- 3 4))
>
> is there anyway to rewirte that last line:
>
> (raise (list ...)) somehow in the format of:
>
> (raise '(....))
I'm not sure I understand what it is you want. Can you give a typical
input and output for your macro? Isn't the parameter to "raise"
supposed to change depending on the run time value of the expressions
lhs and rhs? That can't be done with a quote, however maybe you don't
mind using a quasiquote which is equivalent to your call to list, i,e,
(quasiquote (a ,b c ,d)) = `(a ,b c ,d) = (list 'a b 'c d), except for
the possible name conflict with "list".
Marc
More information about the Gambit-list
mailing list