I'm trying to work through expanding a macro to pass the result into another macro. I've attached and pasted the spec below that is my toy example. I've tried using expand, but it gives me "(C (#%app (#%top . B) (quote 1) (quote 2)))" instead of "(C (in 1 2))". I've also tried many other things, but none seem to do what I expect/want. Any help?
#lang racket
(require (for-syntax syntax/parse))
; I want A to take a (B x y) expand it to be passed to C.
; (A (B 1 2))
; -> (C (in 1 2))
(define-syntax (A stx)
(syntax-case stx (A)
[(A b)
(with-syntax ([expanded-b #'b]) ; <- what goes here?
#'(C expanded-b))]))
(define-syntax (B stx)
(syntax-case stx (B)
[(B x y)
#'(in x y)]))
(define-syntax (C stx)
(syntax-case stx (C in)
[(C (in x y))
#'(printf "~a ~a ~n" x y)]))
(A (B 1 2)) ; expect to print "1 2 ~n"
Thanks!
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/dd6d4e30-9fd9-4e29-9d36-3a4b0935fc4ao%40googlegroups.com.
testing-macros.rkt
Description: Binary data

