Hi everyone,

Here's another plea for help from the macro experts. I am trying to
write a macro whose expansion contains another macro, more precisely a
let-syntax form. My full example is attached below. In the first part,
I use a let-syntax directly. In the second part, I use a macro that
generates exactly the form that I wrote by hand in the first part -
but then the let-syntax seems to be ignored.

The macro stepper isn't of much help here. It shows the expansion
of (defn (foo2 ...)) into essentially what I wrote by hand for foo1,
and then declares the expansion finished.

Can anyone tell me (1) why this doesn't work and (2) how to fix it?

Thanks in advance,
  Konrad.

======================================================================
#lang racket

(require syntax/parse)
(require (for-syntax syntax/parse))

;
; this works fine
;
(define (foo1 x y)
  (let-syntax ([send (λ (stx)
                       (syntax-parse stx
                         ((send obj:expr method:id x:expr ...)
                          #'(method obj x ...))))])
    (send x + y)))

(foo1 2 3)

;
; this doesn't
;
(define-syntax (def stx)
  (syntax-parse stx
    [(_ (fn-name:id arg:id ...) body ... )
     #'(define (fn-name arg ...)
         (let-syntax ([send (λ (stx)
                              (syntax-parse stx
                                [(send obj:expr method:id x:expr (... ...))
                                 #'(method obj x (... ...))]))])
           body ...))]))

(def (foo2 x y)
  (send x + y))

(foo2 2 3)

;; send: target is not an object
;; ;   target: 2
;; ;   method name: +
;; ;

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to