I must be missing something obvious. But I've developed short-term macro 
blindness.

The idea is that the `foo` identifier is packaged into the call to `submac` as 
a syntax property.

When I retrieve this property from inside `mac`, it returns the expected 
'module-foo value.

But when I retrieve this property from inside `submac`, it creates a new 
nonconflicting variable. This confuses me: what I expect is that `submac` 
should try to bind the same identifier, producing an error.


;;;;;;;;;;;;

#lang racket

(define foo 'module-foo)

(define-syntax (mac stx)
  (syntax-case stx ()
    [(_ SUBMAC)
     (with-syntax ([SUBMAC (syntax-property #'SUBMAC 'foo-id #'foo)])
       #`(begin (displayln (format "module foo = ~a" #,(syntax-property 
#'SUBMAC 'foo-id)))
                SUBMAC))]))

(define-syntax (submac stx)
  (syntax-case stx ()
    [(_)
     (with-syntax ([FOO-ID (syntax-property stx 'foo-id)])
       #`(begin
           (define FOO-ID 'submac-foo)
           (displayln (format "submac foo = ~a" FOO-ID))))]))

(mac (submac)) ; why not an "identifier already defined" error?

-- 
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