unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Shinn <alexshinn@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: ‘match’ and “k or more” patterns
Date: Wed, 08 Sep 2010 14:06:00 +0200	[thread overview]
Message-ID: <87sk1ko2xj.fsf@gnu.org> (raw)
In-Reply-To: <AANLkTikKbVssXkdfc=DnKgEJr2xJxsNrbjL1vifqkYV2@mail.gmail.com> (Alex Shinn's message of "Wed, 8 Sep 2010 11:18:18 +0900")

Hi,

Alex Shinn <alexshinn@gmail.com> writes:

> On Mon, Sep 6, 2010 at 9:12 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>>
>> Well, since there are only 9 of them, they could probably be implemented
>> as special cases, with an augmented ‘match-gen-ellipses’, which would be
>> told the minimum number of elements expected?
>
> Oh, the Wright syntax limited you to 9 forms, so "..10" is illegal?

From Wright’s 1995 paper & doc I thought k > 9 wasn’t supported but
apparently it is:

--8<---------------cut here---------------start------------->8---
guile> (use-modules (ice-9 match)) ;; <- Wright’s code
guile> (match (iota 30) ((a ..10) a))
$1 = (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29)
guile> (match (iota 30) ((a ..22) a))
$2 = (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29)
guile> (version)
$3 = "1.8.7"
--8<---------------cut here---------------end--------------->8---

:-(

> "..1" is actually useful - it's the analog of "+" in regular
> expressions, and allows simplifying many syntax-rules
> patterns you see written (elt0 elt1 ...) as (elt ..1).  If
> the elements are more complex patterns this is a big
> win.

Agreed.

So perhaps one solution would be to:

  1. Have a special case for ‘..1’, since it’s quite handy.

  2. Have a new syntax form, like ‘.. k’, as you suggested.

What do you think?

Thanks,
Ludo’.



  reply	other threads:[~2010-09-08 12:06 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
2010-09-06 12:12   ` Ludovic Courtès
2010-09-08  2:18     ` Alex Shinn
2010-09-08 12:06       ` Ludovic Courtès [this message]
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=87sk1ko2xj.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=alexshinn@gmail.com \
    --cc=guile-devel@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).