aboutsummaryrefslogtreecommitdiffstats
path: root/match.csc
diff options
context:
space:
mode:
Diffstat (limited to 'match.csc')
-rw-r--r--match.csc11
1 files changed, 10 insertions, 1 deletions
diff --git a/match.csc b/match.csc
index 07ca98c..d188349 100644
--- a/match.csc
+++ b/match.csc
@@ -40,10 +40,19 @@
(define-syntax match
- (syntax-rules ()
+ (syntax-rules (when)
+ ((match x (pattern (when condition) result result* ...))
+ (if (and (matches? x pattern)
+ condition)
+ (bind-pattern x pattern result result* ...)))
((match x (pattern result1 result2 ...))
(if (matches? x pattern)
(bind-pattern x pattern result1 result2 ...)))
+ ((match x (pattern (when condition) result result* ...) clause clause* ...)
+ (if (and (matches? x pattern)
+ condition)
+ (bind-pattern x pattern result result* ...)
+ (match x clause clause* ...)))
((match x (pattern result1 result2 ...) clause1 clause2 ...)
(if (matches? x pattern)
(bind-pattern x pattern result1 result2 ...)