[racket] How to use structure inside define-syntax ?

From: Veer (diggerrrrr at gmail.com)
Date: Thu Apr 21 10:21:54 EDT 2011

Thanks for reply.

(require (for-syntax ...))  is what I actually  needed.
I don't know why I did not try this first , and I read the guide about
this few hours back.

Just for information by adding #:omit-define-syntaxes in:
(begin-for-syntax
   (struct proc-struct (name args loe)
           #:omit-define-syntaxes))

 I get error :

"expand: unbound identifier in module (in phase 1, transformer
environment) in: proc-struct "

But this works :

(begin-for-syntax
   (struct proc-struct (name args loe)
           #:omit-define-syntaxes #:constructor-name make-proc-struct))


Thanks again
Veer.






On Thu, Apr 21, 2011 at 6:56 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Thu, 21 Apr 2011 18:34:45 +0530, Veer wrote:
>> I still get error when i do
>>
>> (begin-for-syntax
>>   (struct proc-struct  (name args loe)))
>>
>> error:  " define-syntaxes: syntax definitions not allowed within
>> begin-for-syntax ..."
>
> This is a limitation of the module system (which I hope to remove one
> day soon). Work around it by adding `#:omit-define-syntaxes':
>
>  (begin-for-syntax
>   (struct proc-struct (name args loe)
>           #:omit-define-syntaxes))
>
>
> You could also use `struct' in a separate module that is imported with
> `(require (for-syntax ...))', but maybe you want to keep everything in
> one module.
>
>



Posted on the users mailing list.