guile-devel
[Top][All Lists]
Advanced

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

Re: ‘match’ and “k or more” patterns


From: Alex Shinn
Subject: Re: ‘match’ and “k or more” patterns
Date: Mon, 6 Sep 2010 10:46:58 +0900

On Mon, Sep 6, 2010 at 12:04 AM, Ludovic Courtès <address@hidden> wrote:
>
> GNU Guile 1.9 now uses your implementation of ‘match’ as a nice
> replacement for Wright’s implementation, so thank you!
>
> I stumbled upon this incompatibility: Wright’s ‘match’ supports ‘..1’,
> ‘..2’, etc., which mean “1 or more”, “2 or more”, etc., and the
> associated variable (when there’s one) is bound to the list that
> matches:
>
>  (match '(a 1 2) (('a x ..1) x))
>  => (1 2)
>
> AFAICS these patterns aren’t implemented in your ‘match’.
>
> Do you have plans to implement them?

Yes, these can't be implemented in syntax-rules.

It would be straightforward to implement an alternate
syntax such as

  (match '(a 1 2) (('a x .. 1) x))

or generalize it to

  (match '(a 1 2) (('a x <M> .. <N>) x))

where the <N> could be #f or left out to mean infinity,
which would be strictly more powerful than Wright's
syntax.

The main reason I haven't bothered adding this is
I've never needed it, and was waiting to hear reports
from people who do.

Do you have any code which actually uses the ..k
patterns? :)

-- 
Alex



reply via email to

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