unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.tampe@spray.se>
To: guile-devel@gnu.org
Subject: Re: new match system bug?
Date: Sat, 4 Sep 2010 15:29:22 +0200	[thread overview]
Message-ID: <201009041529.22455.stefan.tampe@spray.se> (raw)
In-Reply-To: <878w3hy8xq.fsf@gnu.org>

On Saturday, September 04, 2010 02:44:49 pm Ludovic Courtès wrote:
> Hello!
> 
> Stefan Israelsson Tampe <stefan.tampe@spray.se> writes:
> > While eating the dogfood of the new match macro I come across a bug
> > e.g, this does not work!
> > 
> > (match '(a b) ((and x (a ... b)) a))
> 
> But:
> 
>   scheme@(guile-user)> (match '(a b) ((and x (a . b)) a))
>   $1 = a
> 
> According to the grammar in the manual, I don’t think literal ‘...’ can
> be used in the middle of a list; it should only be used at the end of a
> list, where it means “zero or more”:
> 
>   scheme@(guile-user)> (match '(a b) ((a ...) a))
>   $2 = (a b)
> 
> Thanks,
> Ludo’.

How true, It's just that the code we took has an extension with a Bug in it.
It was intended to work for that case as well.

From match.upstream.scm:
;; 2007/07/21 - allowing ellipse patterns in non-final list positions

They just stopped variants of
the form (a ... b ...) cause it led to higher order matchers that could be
avoided by another means me thinks. 

So either.
1. we allow for this extension. or
2. Add a nice error message explaining that that feature is not suported.
   Right now - this is a Bug :-)

Note. I would like to allow multiple a ... patterns but warn against it use 
and change the algorithm. The reason is that there exists a common pattern 
idiom. Namely ( a a a a - b b b b b - c c c c c)  e.g. using separators. 
essentially it is very kind to allow people to do:

   (match list ((x ... '- . l) (begin (handle x) (f l))))

So you essentially allow a anti gready ... operator. Note here that using <x> 
abstractions althogh it works for the above example, it cannot reproduce a non
gready operator. For that you would need the continuation inside the match
abstractions.

Cheers
Stefan







  reply	other threads:[~2010-09-04 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-04 12:38 new match system bug? Stefan Israelsson Tampe
2010-09-04 12:44 ` Ludovic Courtès
2010-09-04 13:29   ` Stefan Israelsson Tampe [this message]
2010-09-04 15:00     ` Ludovic Courtès
2010-09-04 15:17       ` Stefan Israelsson Tampe
2010-09-04 15:02   ` Stefan Israelsson Tampe

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=201009041529.22455.stefan.tampe@spray.se \
    --to=stefan.tampe@spray.se \
    --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).