Consider the following two macros:

(require (for-syntax syntax/parse))

(define-syntax (phone-numbers stx)
  (syntax-parse stx
    [(_ ((~literal number) phone) ...)
     #'(list phone ...)]))

(define x (phone-numbers
           (number "1212")
           (number "2121"))) ; ==> '("1212" "2121")

(define-syntax (add-prefix stx)
  (syntax-parse stx
    [(_ prefix ((~literal number) str) ...)
     #'(list (list 'number (string-append prefix str)) ...)]))

(define y (add-prefix "555"
                      (number "1212")
                      (number "2121"))) ; ==> '((number "5551212") (number 
"5552121"))

I would like to be able to do the following:

(phone-numbers
 (add-prefix "555"
             (number "1212")
             (number "2121"))
 (number "1234")) ; ==> '("5551212" "5552121" "1234")

I was hoping it would be possible to do this without modifying the 
phone-numbers macro. In other words, to have the result of expanding 
add-prefix macro call be:

(number "5551212") (number "5552121")

So that it would appear to the phone-numbers macro as if the user had 
actually typed:

(phone-numbers
  (number "5551212")
  (number "5552121")
  (number "1234"))

Is it possible to do this w/o the explicit cooperation of the phone-numbers 
macro?

Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e6e5a407-7547-44f1-b8c2-bbe7906ed6f5%40googlegroups.com.

Reply via email to