guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inconsistent behaviour of the pattern matcher


From: Panicz Maciej Godek
Subject: Inconsistent behaviour of the pattern matcher
Date: Sun, 28 Apr 2013 10:12:57 +0200

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]