unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Alex Shinn <alexshinn@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Subject: Re: ‘match’ and “k or more” patterns
Date: Mon, 6 Sep 2010 10:46:58 +0900	[thread overview]
Message-ID: <AANLkTik=nycUNouYrBo+iHq+YDZBhC-LGCdLpBAdcDK6@mail.gmail.com> (raw)
In-Reply-To: <877hj0xmcp.fsf@gnu.org>

On Mon, Sep 6, 2010 at 12:04 AM, Ludovic Courtès <ludo@gnu.org> 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	other threads:[~2010-09-06  1:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-05 15:04 ‘match’ and “k or more” patterns Ludovic Courtès
2010-09-06  1:46 ` Alex Shinn [this message]
2010-09-06 12:12   ` Ludovic Courtès
2010-09-08  2:18     ` Alex Shinn
2010-09-08 12:06       ` Ludovic Courtès
2010-09-08 18:53       ` Andy Wingo
2010-09-19 21:30       ` Ludovic Courtès
     [not found]         ` <2083922817.3379621.1285477344869.JavaMail.root@zmbs1.inria.fr>
2010-09-27 21:56           ` Ludovic Courtès
2010-09-28  1:20             ` Alex Shinn
     [not found]             ` <704726234.3471946.1285636813715.JavaMail.root@zmbs1.inria.fr>
2010-09-28 10:27               ` Ludovic Courtès
2010-10-02  7:13                 ` Alex Shinn
2010-10-03 10:24                   ` Andy Wingo
     [not found]                   ` <2087670639.297243.1286101256715.JavaMail.root@zmbs1.inria.fr>
2010-10-03 12:35                     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTik=nycUNouYrBo+iHq+YDZBhC-LGCdLpBAdcDK6@mail.gmail.com' \
    --to=alexshinn@gmail.com \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).