[racket] syntax-case + boxes and hash literals
#lang scribble/lp
I've been to write some macros but I've run into some rather annoying
limitations of syntax-case. They all involve deconstructing/pattern-matching
literal boxes and literal hash tables. As per the pattern grammer in the
reference guide, I can use syntax case to match against vectors, lists, and
prefab structures, like so:
@chunk[<*>
(syntax-case #'(1 #(b 2) #s(silly 3)) ()
[(a #(_ b) #s(silly c))
#'(a b c)])]
However I cannot do the same with boxes or hash literal. I can match syntax that contains boxes, like so:
@chunk[<*>
(syntax-case #'(1 #&2 #(3)) ()
[(a b #(c))
#'(a b c)])]
But I cannot pattern match inside of the box itself. I would have expected that the following return a syntax object containing 1, 2, and 3 in a list. Instead it gives an error that says "?: bad syntax in: (1 #(b 2) #&3)"
@chunk[<*>
(syntax-case #'(1 #(b 2) #&3) ()
[(a #(_ b) #&c)
#'(a b c)])]
Why is this? It's my understanding that syntax-case is an older features, and so perhaps it just wasn't updated when newer constructs arrived. Was this an intentional decision, or did it slip through? If it did, could I ask that it be added to the TODO list?
Thanks,
Matias Eyzaguirre