unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Inconsistent behaviour of the pattern matcher
@ 2013-04-28  8:12 Panicz Maciej Godek
  2013-04-28 12:51 ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: Panicz Maciej Godek @ 2013-04-28  8:12 UTC (permalink / raw)
  To: guile-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-28 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-28  8:12 Inconsistent behaviour of the pattern matcher Panicz Maciej Godek
2013-04-28 12:51 ` 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

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).