guile-user
[Top][All Lists]
Advanced

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

support for (... ...) ellipsis quoting? (Was: local syntax-rules)


From: Ivan Toshkov
Subject: support for (... ...) ellipsis quoting? (Was: local syntax-rules)
Date: Wed, 8 Nov 2000 10:47:30 +0200

Lars J. Aas writes:
 > On Tue, Nov 07, 2000 at 12:23:28PM +0200, Ivan Toshkov wrote:
 > : 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)?
 > : 
 > : 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...
 > 
 > I did, and got this suggestion:
 > 
 >   (define-syntax argtypes
 >     (syntax-rules ()
 >       ((argtypes arg1 ...)
 >         (letrec-syntax ((argtype (syntax-rules ()
 >                                    ((argtype (name type)) type)
 >                                    ((argtype name) <top>)))
 >                         (argtypes (syntax-rules ()
 >                                     ((argtypes arg)
 >                                       (cons (argtype arg) '()))
 >                                     ((argtypes arg arg1 (... ...))
 >                                       (cons (argtype arg)
 >                                             (argtypes arg1 (... ...)))))))
 >           (argtypes arg1 ...)))))
 > 
 > The (... ...) construct is a non-R5RS extension for quoting ellipsis, which
 > supposedly was supported by most R5RS scheme implementations, but it doesn't
 > seem to be supported in Guile because I get this error:
 > 
 > ERROR: missing ellipsis in syntax form (syntax (letrec-syntax ((argtype [...]
 > ABORT: (misc-error)
 > 
 > Can anyone confirm that the (... ...) convention is unsupported?
 > 
 > I'm going to try to rewrite it using the single-dot pattern notation instead
 > (which is R5RS) to see if I can get that to work...
 > 
 >   Lars J
 > 

I looked at R5RS and found something that might be helpful.  In the definitions
of `letrec' and `do', they use a trick like this:

     (define-syntax do
       (syntax-rules ()
         ((do ((var init step ...) ...)
              (test expr ...)
              command ...)
          (letrec
            ((loop
              (lambda (var ...)
                (if test
                    (begin
                      (if #f #f)
                      expr ...)
                    (begin
                      command
                      ...
                      (loop (do "step" var step ...)
                            ...))))))
            (loop init ...)))
         ((do "step" x)
          x)
         ((do "step" x y)
          y)))


Of course, this has the side effect that one can write (do "step" whatever),
which is not in the documentation.

They say that it can be external macro, but don't mention if it can be
``hidden''.  My guess is, that it cannot be.

--
Ivan Toshkov



reply via email to

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