diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-15 01:50:56 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-15 01:50:56 -0800 |
commit | 7bc63c0e2a4e3e410f68acbea555b3877a680d00 (patch) | |
tree | 19607260cfcac47cd83ba73f6a837a8622a2081d | |
parent | fdf400f08013c1a67f17eb8ea466f6653c00fd1a (diff) | |
download | txr-7bc63c0e2a4e3e410f68acbea555b3877a680d00.tar.gz txr-7bc63c0e2a4e3e410f68acbea555b3877a680d00.tar.bz2 txr-7bc63c0e2a4e3e410f68acbea555b3877a680d00.zip |
matcher: allow omitted variabel in predicates
For instance @(oddp) instead of @(oddp x) to require an
element to satisfy oddp without capturing it to a variable.
* share/txr/stdlib/match.tl (compile-predicate-match): Make
the symbolic argument optional, defaulting to nil.
A nil symbol is already treated as pseudo-variable which
consumes an item without binding to a variable.
-rw-r--r-- | share/txr/stdlib/match.tl | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 526e3b3d..18ab6577 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -116,7 +116,7 @@ test-expr ^(equal ,obj-var ',atom))))) (defun compile-predicate-match (pred-expr obj-var) - (tree-bind (fun sym) pred-expr + (tree-bind (fun : sym) pred-expr (or (null sym) (bindable sym) (compile-error *match-form* "~s is not a symbol" sym)) (let ((var-match (compile-var-match sym obj-var))) |