Allow variables in unquote-splicing terms
I think that in general, `null-terminated?` should admit all patterns that _could_ match a list, instead of just the ones that _only_ match a list. That means that `(app f)` patterns and many others should also be valid, though those are harder to implement, so I haven't tried those yet.
This commit is contained in:
parent
4c6bb055b0
commit
b56276c670
|
@ -785,6 +785,11 @@
|
|||
[`(begin ,es ... ,en)
|
||||
(list es en)]))
|
||||
|
||||
(comp '((1 2 3 4) (6 7) (9))
|
||||
(match '(0 1 2 3 4 5 6 7 8 9)
|
||||
[`(0 ,@a 5 ,@b 8 ,@c)
|
||||
(list a b c)]))
|
||||
|
||||
(comp '(a b c)
|
||||
(let ()
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
(cond [(Pair? pat) (null-terminated? (Pair-d pat))]
|
||||
[(GSeq? pat) (null-terminated? (GSeq-tail pat))]
|
||||
[(Null? pat) #t]
|
||||
[(Var? pat) #t]
|
||||
[else #f]))
|
||||
|
||||
;; combine a null-terminated pattern with another pattern to match afterwards
|
||||
|
@ -23,6 +24,12 @@
|
|||
(append-pats (GSeq-tail p1) p2)
|
||||
(GSeq-mutable? p1))]
|
||||
[(Null? p1) p2]
|
||||
[(Var? p1) (make-GSeq (list (list p1))
|
||||
(list #f)
|
||||
(list #f)
|
||||
(list #f)
|
||||
p2
|
||||
#f)]
|
||||
[else (error 'match "illegal input to append-pats")]))
|
||||
|
||||
(define hard-case?
|
||||
|
|
Loading…
Reference in New Issue
Block a user