guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: local syntax-rules


From: Ivan Toshkov
Subject: Re: local syntax-rules
Date: Tue, 7 Nov 2000 12:23:28 +0200

Lars J. Aas writes:
 > On Mon, Nov 06, 2000 at 05:14:08PM +0100, Lars J. Aas wrote:
 > :   (define-syntax argtypes
 > :     (let-syntax ((argtype (syntax-rules ()
 > :                             ((argtype (name type)) type)
 > :                             ((argtype name) <top>))))
 > :       (syntax-rules ()
 > :         ((argtypes arg) (cons (argtype arg) '()))
 > :         ((argtypes arg arg1 ...) (cons (argtype arg) (argtypes arg1 
 > ...))))))
 > : 
 > : Should I use let-syntax in another way (e.g. *inside* the argtypes 
 > syntax-rules)?
 > 

Perhaps the problem is that syntax rules aren't first class scheme objects,
(don't know if it's true) and therefore let-syntax cannot evaluate to a syntax
rule. 

On the other hand, in R5RS is said that there is no analog to local define for
synax definitions, so your problem seems to get tougher.

 > I found putting them inside the rules to work:
 > 
 >   (define-syntax argtypes
 >     (syntax-rules ()
 >       ((argtypes arg)
 >         (let-syntax ((argtype (syntax-rules ()
 >                                 ((argtype (name type)) type)
 >                                 ((argtype name) <top>))))
 >           (cons (argtype arg) '())))
 >       ((argtypes arg arg1 ...)
 >         (let-syntax ((argtype (syntax-rules ()
 >                                 ((argtype (name type)) type)
 >                                 ((argtype name) <top>))))
 >           (cons (argtype arg) (argtypes arg1 ...))))))
 > 
 > However, this makes me have to repeat the submacros for each public 
 > syntax-rule,
 > making the whole thing an unreadable mess.  Isn't a shared approach (like the
 > invalid example on top) possible?  I tried to enclose the syntax rules 
 > through
 > let-variables, but that didn't work either:
 > 
 >   (define-syntax argtypes
 >     (let ((argtype-rules (syntax-rules ()
 >                            ((argtype (name type)) type)
 >                            ((argtype name) <top>))))
 >       (syntax-rules ()
 >         ((argtypes arg)
 >           (let-syntax (argtype argtype-rules)
 >             (cons (argtype arg) '())))
 >         ((argtypes arg arg1 ...)
 >           (let-syntax (argtype argtype-rules)
 >             (cons (argtype arg) (argtypes arg1 ...)))))))
 > 
 > Any suggestions?  I'll rather use public sub-macros than the let-syntax 
 > approach
 > I found to work...
 > 

If I think of something I'll let you know :)  Meanwhile, why don't you try to
post your question in comp.lang.scheme and see what they have to say about it?
I guess most of the guile developers/users prefer lisp-style macros and that's
why you don't get many answers here...

 >   Lars J
 > 
 > _______________________________________________
 > Guile-user mailing list
 > address@hidden
 > http://mail.gnu.org/mailman/listinfo/guile-user
 > 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]