Treat static struct info as pattern constructor.

This commit is contained in:
Sam Tobin-Hochstadt 2010-04-26 11:42:48 -04:00
parent 1cf22896ce
commit 8047e32662
2 changed files with 13 additions and 0 deletions

View File

@ -153,6 +153,9 @@
[(mcons e1 e2) (make-MPair (parse #'e1) (parse #'e2))]
[(struct s pats)
(parse-struct stx cert parse #'s #'pats)]
[(s . pats)
(struct-info? (syntax-local-value #'s (lambda () #f)))
(parse-struct stx cert parse #'s #'pats)]
[(? p q1 qs ...)
(make-And (cons (make-Pred (cert #'p))
(map parse (syntax->list #'(q1 qs ...)))))]

View File

@ -113,6 +113,16 @@
[(box a) a]
[(cons x y) (+ x y)]
[_ 0])))
(comp
6
(let ()
(match (make-X 1 2 3)
[(X a b c) (+ a b c)]
[(box a) a]
[(cons x y) (+ x y)]
[_ 0])))
(comp
6