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 '(....))
Afficher les réponses par date
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