[plt-scheme] Macros which expand to uses of (call-next-method)
Hey all,
I'm writing a macro which expands into a use of (call-next-method)
inside a (defmethod ...) from swindle:
(define-syntax define-binary-derivative
(lambda (stx)
(syntax-case stx ()
((_ f df/dx df/dy)
(let ((cnm (datum->syntax-object #f 'call-next-method)))
#`(begin
(defmethod (f (d1 <deriv>) (d2 <deriv>))
(with-slots d1 ((id1 'id) x dx)
(with-slots d2 ((id2 'id) (y 'x) (dy 'dx))
(if (eq? id1 id2)
(make <deriv>
:id id1
:x (f x y)
:dx (+ (* (df/dx x y) dx)
(* (df/dy x y) dy)))
(#,cnm)))))
(defmethod (f (d <deriv>) y)
(with-slots d (id x dx)
(make <deriv>
:id id
:x (f x y)
:dx (* (df/dx x y) dx))))
(defmethod (f x (d <deriv>))
(with-slots d (id (y 'x) (dy 'dx))
(make <deriv>
:id id
:x (f x y)
:dx (* (df/dy x y) dy))))))))))
The system complains:
compile: bad syntax; reference to top-level identifier is not allowed,
because no #%top syntax transformer is bound in: call-next-method
If I don't introduce call-next-method with datum->syntax-object, I get
errors about call-next-method being undefined. Is there *any* context
I can use to introduce call-next-method so that this works, or am I
just hosed?
Thanks!
Will