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

From: Jos Koot (jos.koot at telefonica.net)
Date: Thu Apr 21 09:26:40 EDT 2011

Well, I didn't try it.
It appears that you cannot define a syntax within a begin for syntax.
The following works:

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

However you'll miss the the structure type descriptor.

Another way is to define the struct in a seperate module and to provide all
defined and require the module for syntax.
This time I checked and it works.
Jos 

> -----Original Message-----
> From: Veer [mailto:diggerrrrr at gmail.com] 
> Sent: 21 April 2011 15:05
> To: Jos Koot
> Cc: users at racket-lang.org
> Subject: Re: [racket] How to use structure inside define-syntax ?
> 
> Thanks for reply Jos.
> 
> 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 ..."
> 
> Sorry , if this is not what you meant.
> 
> 
> On Thu, Apr 21, 2011 at 6:06 PM, Jos Koot 
> <jos.koot at telefonica.net> wrote:
> > Wrap the definition of the struct in begin-for-syntax.
> > Jos
> >
> >> -----Original Message-----
> >> From: users-bounces at racket-lang.org
> >> [mailto:users-bounces at racket-lang.org] On Behalf Of Veer
> >> Sent: 21 April 2011 14:22
> >> To: users at racket-lang.org
> >> Subject: [racket] How to use structure inside define-syntax ?
> >>
> >> How do I use  structure's constructor in define-syntax .
> >>
> >> I want to do something like this :
> >>
> >> (struct proc-struct (name args loe))
> >>
> >> (define-for-syntax (process ps)
> >>   #'#t)
> >>
> >>
> >> (define-syntax (procedure stx)
> >>   (syntax-case stx ()
> >>     [(_ name args e1 e2 ...)
> >>      (process (proc-struct #'name (syntax->list #'args) 
> (syntax->list
> >> #'(e1 e2 ...))))]))
> >>
> >>
> >>
> >> (procedure abc (x y) 2 3)
> >>
> >>
> >> Is there something like struct-for-syntax ?
> >>
> >> Thanks
> >> _________________________________________________
> >>   For list-related administrative tasks:
> >>   http://lists.racket-lang.org/listinfo/users
> >
> >




Posted on the users mailing list.