summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-19 11:47:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-19 11:47:12 -0700
commitf374abcd23a63f628a9ec7b84e2d797d3fc28342 (patch)
tree811149d630ffaefaa8be464465f660ba9287fc98
parent46be04f43613e08af5015485ff19bb79af1d3feb (diff)
downloadtxr-f374abcd23a63f628a9ec7b84e2d797d3fc28342.tar.gz
txr-f374abcd23a63f628a9ec7b84e2d797d3fc28342.tar.bz2
txr-f374abcd23a63f628a9ec7b84e2d797d3fc28342.zip
matcher: rename error-throwing macros.
* stdlib/match.tl (must-match): Renamed to just match. It's just when-match without the "when". (must-match-case): Renamed to match-ecase, consistent with the case -> ecase naming scheme. * lisplib.c (match_set_entries): Names updated here. * tests/011/patmatch.tl: Test cases updated. * txr.1: Names updated here. * stdlib/doc-syms.tl: Updated.
-rw-r--r--lisplib.c4
-rw-r--r--stdlib/doc-syms.tl10
-rw-r--r--stdlib/match.tl8
-rw-r--r--tests/011/patmatch.tl10
-rw-r--r--txr.116
5 files changed, 24 insertions, 24 deletions
diff --git a/lisplib.c b/lisplib.c
index 58de568c..f1e41547 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -882,8 +882,8 @@ static val match_set_entries(val dlt, val fun)
nil
};
val name[] = {
- lit("when-match"), lit("match-case"), lit("if-match"), lit("must-match"),
- lit("must-match-case"),
+ lit("when-match"), lit("match-case"), lit("if-match"),
+ lit("match"), lit("match-ecase"),
lit("while-match"), lit("while-match-case"), lit("while-true-match-case"),
lit("lambda-match"), lit("defun-match"), lit("defmatch"),
lit("each-match"), lit("append-matches"),
diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl
index 48eb6624..b9877466 100644
--- a/stdlib/doc-syms.tl
+++ b/stdlib/doc-syms.tl
@@ -968,7 +968,7 @@
("ido" "N-011CFC0C")
("iexten" "N-0072FF5E")
("if" "D-001D")
- ("if-match" "N-00D595FF")
+ ("if-match" "N-01BE5C4A")
("ifa" "N-018F39B0")
("iff" "N-000E3A74")
("iffi" "N-000E3A74")
@@ -1206,7 +1206,9 @@
("maprod" "N-015987D7")
("maprodo" "N-015987D7")
("mask" "N-0056CEF1")
- ("match-case" "N-00E4CE2A")
+ ("match" "N-01BE5C4A")
+ ("match-case" "N-0282196B")
+ ("match-ecase" "N-0282196B")
("match-fun" "N-033F766A")
("match-regex" "N-02E3A26F")
("match-regex-right" "N-019430C5")
@@ -1253,8 +1255,6 @@
("mode-t" "N-01D716FE")
("multi" "N-034946BA")
("multi-sort" "N-0132852F")
- ("must-match" "N-00D595FF")
- ("must-match-case" "N-00E4CE2A")
("n-choose-k" "N-02ACFDE6")
("n-perm-k" "N-02ACFDE6")
("name" "N-01557906")
@@ -2058,7 +2058,7 @@
("wait" "N-0365C3E1")
("weave" "N-0208F32F")
("when" "N-017EFAB6")
- ("when-match" "N-00D595FF")
+ ("when-match" "N-01BE5C4A")
("whena" "N-005C93DF")
("whenlet" "N-02DA21F6")
("where" "N-0208F1DE")
diff --git a/stdlib/match.tl b/stdlib/match.tl
index 81f8d8a7..30389ce1 100644
--- a/stdlib/match.tl
+++ b/stdlib/match.tl
@@ -645,12 +645,12 @@
,result
,else)))))
-(defmacro must-match (pat obj . body)
+(defmacro match (pat obj . body)
(with-gensyms (val)
^(let ((,val ,obj))
(if-match ,pat ,val
(progn ,*body)
- (throwf 'match-error "~s: ~s failed to match object ~s" 'must-match ',pat ,val)))))
+ (throwf 'match-error "~s: ~s failed to match object ~s" 'match ',pat ,val)))))
(defmacro while-match (:form *match-form* :env e pat obj . body)
(let ((cm (compile-match pat : (get-var-list e))))
@@ -683,11 +683,11 @@
(or ,*clause-code)
,result-temp))))
-(defmacro must-match-case (obj . clauses)
+(defmacro match-ecase (obj . clauses)
(with-gensyms (else)
^(match-case ,obj
,*clauses
- ((var ,else) (throwf 'match-error "~s: failed to match object ~s" 'must-match-case ,else)))))
+ ((var ,else) (throwf 'match-error "~s: failed to match object ~s" 'match-ecase ,else)))))
(defmacro while-match-case (:form *match-form* :env e obj . clauses)
(unless [all clauses [andf proper-listp [chain len plusp]]]
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index c6b67614..09d294a8 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -514,13 +514,13 @@
(:odd 1 :pair 2 3 :even 4 :pair 5 6))
(mtest
- (must-match (@a @b) '(1 2) (list a b)) (1 2)
- (must-match (@a @b) '(1 2 3) (list a b)) :error)
+ (match (@a @b) '(1 2) (list a b)) (1 2)
+ (match (@a @b) '(1 2 3) (list a b)) :error)
(mtest
- (must-match-case 42) :error
- (must-match-case 42 (@a a)) 42
- (must-match-case '(1 2) ((@a) a)) :error)
+ (match-ecase 42) :error
+ (match-ecase 42 (@a a)) 42
+ (match-ecase '(1 2) ((@a) a)) :error)
(compile-only
(eval-only
diff --git a/txr.1 b/txr.1
index a5d884f3..c81e1063 100644
--- a/txr.1
+++ b/txr.1
@@ -43157,10 +43157,10 @@ apply accordingly.
.SS* Pattern-Matching Macros
-.coNP Macros @, when-match @ must-match and @ if-match
+.coNP Macros @, when-match @ match and @ if-match
.synb
.mets (when-match < pattern < expr << form *)
-.mets (must-match < pattern < expr << form *)
+.mets (match < pattern < expr << form *)
.mets (if-match < pattern < expr < then-form <> [ else-form ])
.syne
.desc
@@ -43192,11 +43192,11 @@ If the match fails, the forms are not evaluated, and
is produced.
The
-.code must-match
+.code match
macro behaves exactly like
.code when-match
when the match is successful. When the match fails,
-.code must-match
+.code match
throws an exception of type
.codn match-error .
@@ -43213,10 +43213,10 @@ which defaults to
.code nil
if it is not specified.
-.coNP Macros @ match-case and @ must-match-case
+.coNP Macros @ match-case and @ match-ecase
.synb
.mets (match-case < expr >> {( pattern << form *)}*)
-.mets (must-match-case < expr >> {( pattern << form *)}*)
+.mets (match-ecase < expr >> {( pattern << form *)}*)
.syne
.desc
The
@@ -43261,7 +43261,7 @@ or else
if there are no forms.
The
-.code must-match-case
+.code match-ecase
macro differs from
.code match-case
as follows. When none of the clauses match under
@@ -43269,7 +43269,7 @@ as follows. When none of the clauses match under
then that form terminates with a value of
.codn nil .
In the same situation, the
-.code must-match-case
+.code match-ecase
form throws an exception of type
.codn match-error .