From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: Inconsistent behaviour of the pattern matcher Date: Sun, 28 Apr 2013 18:29:18 +0200 Message-ID: References: <877gjm24yj.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec52162f30f1a1604db6e459a X-Trace: ger.gmane.org 1367166563 22663 80.91.229.3 (28 Apr 2013 16:29:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Apr 2013 16:29:23 +0000 (UTC) Cc: guile-devel , Panicz Maciej Godek To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Apr 28 18:29:27 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UWUTf-0006zU-0o for guile-devel@m.gmane.org; Sun, 28 Apr 2013 18:29:27 +0200 Original-Received: from localhost ([::1]:44937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWUTe-0006yc-Ct for guile-devel@m.gmane.org; Sun, 28 Apr 2013 12:29:26 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWUTZ-0006yV-Kk for guile-devel@gnu.org; Sun, 28 Apr 2013 12:29:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWUTY-0006pr-99 for guile-devel@gnu.org; Sun, 28 Apr 2013 12:29:21 -0400 Original-Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]:58005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWUTY-0006oJ-24 for guile-devel@gnu.org; Sun, 28 Apr 2013 12:29:20 -0400 Original-Received: by mail-pb0-f52.google.com with SMTP id mc17so1453281pbc.39 for ; Sun, 28 Apr 2013 09:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=K94pA6x64VH5quYA6ztQghXHRsk6HOF6vehdea2HzAk=; b=y1quiZcK6JA0OSgxuKP5EBpo1akgkDUG6MV80eP0BUNPWUyRfRAFc23CKoqOcXb1q6 xu8DDvuR3tcd2EAa2crO3BPTm0XtSCS1iyjARlpfErYGQgb7Kr+Kg/PcsQozK7A56f2Z JQHccUYQUR4LTV8ppZ6zVfB6Ry+BbFizEj+sxUDZq4zcQ64dcR6atXky1ZmwhS8LQhFE br/TExMSrLfb3vpQ0A53pZrq4vqMy1kIsJKrpvBjjxFsSW5vLwI9fYYqWbUEkH2ge7As lUZavMS//BEk02d+wsI/wO9Xh0kakYFQis5JVMu3wREvqXiG6Qe3b9wQ7z1sk8HLRTCx J+OA== X-Received: by 10.68.27.9 with SMTP id p9mr3025377pbg.139.1367166558343; Sun, 28 Apr 2013 09:29:18 -0700 (PDT) Original-Received: by 10.70.22.5 with HTTP; Sun, 28 Apr 2013 09:29:18 -0700 (PDT) In-Reply-To: <877gjm24yj.fsf@tines.lan> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::234 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16303 Archived-At: --bcaec52162f30f1a1604db6e459a Content-Type: text/plain; charset=ISO-8859-1 On Sun, Apr 28, 2013 at 2:51 PM, Mark H Weaver wrote: > Panicz Maciej Godek writes: > > > I've traced something that is not entirely a bug, but which was a > > little surprise for me. It has to do with the extensions that guile > > provides to the Scheme language -- namely, uniform vectors and arrays. > > > > The (ice-9 match) module offers the syntax > > (match #(1 2 3) > > (#(a b c) > > (list a b c))) > > ;===> (1 2 3) > > > > However, none of the following behaves as one could expect: > > (match #u8(1 2 3) > > (#u8(a b c) > > (list a b c))) > > This can't work because a uniform numeric vector cannot hold symbols, so > #u8(a b c) cannot be represented in the source code. > > please note a b c binds to values and is not symbols as in the pmatch matcher or match quasiquoute patterns. So with the right binder this could work. > If you want generic accessors, I guess the array accessors are what you > want. Patches to extend the pattern matcher to handle arrays are > welcome :) Actually for ice-9 match we would like the upstream version to implement these concepts Try ask foof on irc #scheme if he accept a patch to implement this in a portable way or ask him if he thinks he could spend time on it! Only if we could accept a slow implementation of the matcher we can implement a general vector matcher by patching vector-ref etc. /Stefan --bcaec52162f30f1a1604db6e459a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Sun, Apr 28, 2013 at 2:51 PM, Mark H Weaver &l= t;mhw@netris.org>= ; wrote:
Panicz Maciej Godek <godek.maciek@gmail.com> writ= es:

> I've traced something that is not entirely a bug, but which was a<= br> > little surprise for me. It has to do with the extensions that guile > provides to the Scheme language -- namely, uniform vectors and arrays.=
>
> The (ice-9 match) module offers the syntax
> (match #(1 2 3)
> (#(a b c)
> (list a b c)))
> ;=3D=3D=3D> (1 2 3)
>
> However, none of the following behaves as one could expect:
> (match #u8(1 2 3)
> (#u8(a b c)
> (list a b c)))

This can't work because a uniform numeric vector cannot hold symb= ols, so
#u8(a b c) cannot be represented in the source code.

please note a b c binds= to values and is not symbols as in the pmatch matcher or match quasiquoute=
patterns. So with the right binder this could work.
=A0
If you want generic accessors, I guess the array accessors are what you
want. =A0Patches to extend the pattern matcher to handle arrays are
welcome :)

Actually for ice-9 match w= e would like the upstream version to implement these concepts
Try ask foof on irc #scheme if he accept a patch to implement this in a = portable way or ask
him if he thinks he could spend time on it!
=A0<= /div>
Only if we could accept a slow implementation of the matche= r we can implement a general vector
matcher by patching vec= tor-ref etc.

/Stefan
--bcaec52162f30f1a1604db6e459a--