From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: =?utf-8?b?4oCYbWF0Y2jigJk=?= and =?utf-8?b?4oCcaw==?= or =?utf-8?b?bW9yZeKAnQ==?= patterns Date: Mon, 06 Sep 2010 14:12:08 +0200 Message-ID: <874oe36pgn.fsf@gnu.org> References: <877hj0xmcp.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1283775652 3371 80.91.229.12 (6 Sep 2010 12:20:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 6 Sep 2010 12:20:52 +0000 (UTC) Cc: guile-devel@gnu.org To: Alex Shinn Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 06 14:20:46 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Osagn-0007fO-PF for guile-devel@m.gmane.org; Mon, 06 Sep 2010 14:20:46 +0200 Original-Received: from localhost ([127.0.0.1]:56338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Osagm-0001Bx-Ce for guile-devel@m.gmane.org; Mon, 06 Sep 2010 08:20:44 -0400 Original-Received: from [140.186.70.92] (port=60312 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsagW-00011e-MM for guile-devel@gnu.org; Mon, 06 Sep 2010 08:20:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsaYU-000870-AY for guile-devel@gnu.org; Mon, 06 Sep 2010 08:12:12 -0400 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:36588) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsaYU-00086g-0X for guile-devel@gnu.org; Mon, 06 Sep 2010 08:12:10 -0400 X-IronPort-AV: E=Sophos;i="4.56,325,1280700000"; d="scan'208";a="66992131" Original-Received: from laptop-147-210-128-193.labri.fr (HELO nixey) ([147.210.128.193]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 06 Sep 2010 14:12:08 +0200 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 20 Fructidor an 218 de la =?iso-8859-1?Q?R=E9volutio?= =?iso-8859-1?Q?n?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Alex Shinn's message of "Mon, 6 Sep 2010 10:46:58 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10867 Archived-At: Hi, [Re-adding Cc: guile-devel@gnu.org.] Alex Shinn writes: > On Mon, Sep 6, 2010 at 12:04 AM, Ludovic Court=C3=A8s wrot= e: >> >> GNU Guile 1.9 now uses your implementation of =E2=80=98match=E2=80=99 as= a nice >> replacement for Wright=E2=80=99s implementation, so thank you! >> >> I stumbled upon this incompatibility: Wright=E2=80=99s =E2=80=98match=E2= =80=99 supports =E2=80=98..1=E2=80=99, >> =E2=80=98..2=E2=80=99, etc., which mean =E2=80=9C1 or more=E2=80=9D, =E2= =80=9C2 or more=E2=80=9D, etc., and the >> associated variable (when there=E2=80=99s one) is bound to the list that >> matches: >> >> =C2=A0(match '(a 1 2) (('a x ..1) x)) >> =C2=A0=3D> (1 2) >> >> AFAICS these patterns aren=E2=80=99t implemented in your =E2=80=98match= =E2=80=99. >> >> Do you have plans to implement them? > > Yes, these can't be implemented in syntax-rules. Well, since there are only 9 of them, they could probably be implemented as special cases, with an augmented =E2=80=98match-gen-ellipses=E2=80=99, w= hich would be told the minimum number of elements expected? > 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 .. ) x)) > > where the could be #f or left out to mean infinity, > which would be strictly more powerful than Wright's > syntax. Yes, this would be nice, too. > 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? :) I do! :-) http://git.sv.gnu.org/cgit/guile-rpc.git/tree/modules/rpc/compiler.scm#n3= 12 Well it uses only =E2=80=98..1=E2=80=99. The same code would work with =E2= =80=98..1=E2=80=99 replaced by =E2=80=98...=E2=80=99, but then errors in the input wouldn=E2=80=99t be = detected as nicely. Thanks, Ludo=E2=80=99.