unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Inconsistent behaviour of the pattern matcher
Date: Sun, 28 Apr 2013 10:12:57 +0200	[thread overview]
Message-ID: <CAMFYt2bTQgtwNnYzbGrK6PiRVVSNexou7-1fe3o4Ej3zauSJoQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

Hi,
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)))

(match #2((1 2)(3 4))
  (#2((a b)(c d))
   (list a b c d)))

(match #u8(1 2 3); this is perhaps questionable, but
  (#(a b c) ; i add it for a discussion
  (list a b c)))

After looking into the source of the pattern matcher, I've found out that
the problem is probably situated deeper: while it is possible to define
macros with regular vectors, like that:

(define-syntax nv
  (syntax-rules ()
    ((nv #(v ...))
     (list v ...))))

it doesn't work if we replace the #(v ...) with #u8(v ...), for instance.

Best regards,
M.

[-- Attachment #2: Type: text/html, Size: 1569 bytes --]

             reply	other threads:[~2013-04-28  8:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-28  8:12 Panicz Maciej Godek [this message]
2013-04-28 12:51 ` Inconsistent behaviour of the pattern matcher Mark H Weaver
2013-04-28 16:29   ` Stefan Israelsson Tampe
2013-04-28 17:30     ` Mark H Weaver
2013-04-28 18:18       ` 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=CAMFYt2bTQgtwNnYzbGrK6PiRVVSNexou7-1fe3o4Ej3zauSJoQ@mail.gmail.com \
    --to=godek.maciek@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).