Panicz Maciej Godek <godek.mac...@gmail.com> 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. > (match #2((1 2)(3 4)) > (#2((a b)(c d)) > (list a b c d))) This could be made to work, but has not been implemented. > (match #u8(1 2 3); this is perhaps questionable, but > (#(a b c) ; i add it for a discussion > (list a b c))) This should not work, IMO, because uniform numeric vectors are a distinct type from normal vectors, and making the normal vector accessors work with the other vector-like types would necessarily make them much slower when we have native code generation. 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 :) > 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. Again, a #u8 vector cannot hold symbols, so this cannot work. Regards, Mark