summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/txr/stdlib/match.tl4
-rw-r--r--txr.137
2 files changed, 29 insertions, 12 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl
index 09f1c068..0c672903 100644
--- a/share/txr/stdlib/match.tl
+++ b/share/txr/stdlib/match.tl
@@ -180,9 +180,9 @@
var-exprs (append car-match.var-exprs cdr-match.var-exprs)))))
(defun compile-require-match (exp obj-var)
- (mac-param-bind *match-form* (op match condition) exp
+ (mac-param-bind *match-form* (op match . conditions) exp
(let ((match (compile-match match obj-var)))
- (set match.test-expr ^(and ,condition ,match.test-expr))
+ (set match.test-expr ^(and ,match.test-expr ,*conditions))
match)))
(defun compile-let-match (exp obj-var)
diff --git a/txr.1 b/txr.1
index cde66385..679b91a4 100644
--- a/txr.1
+++ b/txr.1
@@ -39934,7 +39934,7 @@ as its value.
.coNP Pattern operator @ require
.synb
-.mets @(require < pattern << expression *)
+.mets @(require < pattern << condition *)
.syne
.desc
The pattern operator
@@ -39944,19 +39944,36 @@ applies the specified
to the corresponding object.
If the
.meta pattern
-matches, the operator then imposes the additional conditions specified by
-the extra
-.metn expression .
-The
-.meta expression
+matches, the operator then imposes the additional constraints
+specified by zero or more
+.meta condition
+forms.
+Each
+.meta condition
is evaluated in a scope in which the variables from
.meta pattern
have already been established.
-However, the mach is considered to have succeeded only if
-.meta expression
-yields true. If it yields
+
+For the
+.code require
+operator to be a successful match, every
+.meta condition
+must evaluate true, otherwise the match fails.
+
+The
+.meta condition
+forms behave as if they were the arguments of an implicit
+.code and
+operator, which implies left-to-right evaluation behavior, stopping
+evaluation on the first
+.meta condition
+which produces
.codn nil ,
-then the match is deemed to have failed.
+and defaulting to a result of
+.code t
+when no
+.meta condition
+forms are specified.
.TP* Examples: