[racket] Binding undefined with a macro

From: antoine (antoine597 at gmail.com)
Date: Tue Sep 3 12:23:17 EDT 2013

Hello,

With this macro:

(define-syntax (struct-abc stx)
   (syntax-case stx ()
     [(_ name (args ...) props ...)
      #`(begin
      (+ 1 1)
      (struct name (args ...) props ...
          #:property prop:insiders person-name))]))

(define-values (prop:insiders insiders? insiders-ref)
   (make-struct-type-property 'insider))


When i do :

(struct-abc person (name nickname))

I get :

person-name: undefined;
  cannot reference an identifier before its definition

But i know that person-name is defined the problem come from 'begin' in 
the macro, if i rewrite like this :

(define-syntax (struct-abc stx)
   (syntax-case stx ()
     [(_ name (args ...) props ...)
      #`(struct name (args ...) props ...
          #:property prop:insiders person-name)]))

It works as expected.

So my question are:

Could you explain (point out) me why the person-name is unknown at this 
point?
And how can i change the begin with something like '#,@'?

Thank you.

Posted on the users mailing list.