diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-06 19:14:21 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-06 19:14:21 -0800 |
commit | acdc6a768282aeb3d0e592481952233b08b3b838 (patch) | |
tree | 447e8f7096e0867092bedca86096fcb4e7ec06a9 | |
parent | 777eb4e599dd13797fbf7f458717a3ceff71b94d (diff) | |
download | txr-acdc6a768282aeb3d0e592481952233b08b3b838.tar.gz txr-acdc6a768282aeb3d0e592481952233b08b3b838.tar.bz2 txr-acdc6a768282aeb3d0e592481952233b08b3b838.zip |
matcher: remove @(op ...) pattern.
All he typical uses of this are better served by the new
predicate match. If op is really needed, it can be used with
the DWIM form of the predicate, as in @[(op ...) ...].
* share/txr/stdlib/match.tl (compile-op-match): Function
removed.
(compile-match): Remove op case.
* tests/011/patmatch.tl: Keep op test cases by converting them
to predicate test cases.
* txr.1: Documentation removed.
-rw-r--r-- | share/txr/stdlib/match.tl | 7 | ||||
-rw-r--r-- | tests/011/patmatch.tl | 4 | ||||
-rw-r--r-- | txr.1 | 32 |
3 files changed, 2 insertions, 41 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 8fbac8f8..a0339fab 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -270,12 +270,6 @@ (compile-as-atom))) (t (compile-as-atom))))) -(defun compile-op-match (op-expr obj-var var-list) - (let ((var-match (compile-var-match nil obj-var var-list))) - var-match.(add-guard-pre (new match-guard - guard-expr ^ [,op-expr ,obj-var])) - var-match)) - (defun compile-predicate-match (exp obj-var var-list) (let ((head (car exp))) (if (and (consp head) (eq (car head) 'sys:var)) @@ -561,7 +555,6 @@ (or (compile-or-match exp obj-var var-list)) (and (compile-and-match exp obj-var var-list)) (not (compile-not-match exp obj-var var-list)) - (op (compile-op-match exp obj-var var-list)) (hash (compile-hash-match exp obj-var var-list)) (rcons (compile-range-match exp obj-var var-list)) (exprs (compile-exprs-match exp obj-var var-list)) diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index d30f5aec..8c8aae59 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -83,8 +83,8 @@ (test (when-match (@(oddp) @(all @x)) '(2 (1 2 . 3)) x) nil) (test (if-match @(or (@x 3 3) (1 @x 3) (1 2 @x)) '(1 2 3) x) 2) -(test (if-match @(op <= 10 @1 13) 11 :yes :no) :yes) -(test (when-match @(as x @(op <= 10 @1 13)) 11 x) 11) +(test (if-match @(<= 10 @a 13) 11 :yes :no) :yes) +(test (when-match @(as x @(<= 10 @a 13)) 11 x) 11) (test (when-match (@(evenp) @(oddp @x)) '(2 3) x) 3) (test (when-match @(<= 1 @x 10) 4 x) 4) (test (when-match @(@d (chr-digit @c)) #\5 (list d c)) (5 #\5)) @@ -40676,38 +40676,6 @@ operator. --> (:case2 3 2) .brev -.coNP Pattern operator @ op -.synb -.mets @(op << form +) -.syne -.desc -The -.code op -operator uses the syntax of the -.code op -macro to produce an anonymous function, which is used as the basis of a -predicate match. The function is applied to the corresponding object. -If the function yields true, the match succeeds, otherwise it fails. - -The syntax and semantics of -.code op -is exactly that of the -.code op -macro. - -The syntax must be used in such a way that the resulting anonymous -function is capable of being called with exactly one argument. - -.TP* Example - -.verb - ;; 11 matches, since it is in the 10-13 range - (if-match @(op <= 10 @1 13) 11 :yes :no) -> :yes - - ;; as can be used to capture into a variable - (when-match @(as x @(op <= 10 @1 13)) 11 x) -> 11 -.brev - .NP* Pattern predicate operator .synb .mets >> @( function << arg *) |