summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-02-01 21:44:29 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-02-01 21:44:29 -0800
commitf98f2a73750bff9b182c74d073a9c78e5316d7ae (patch)
tree007c8b8d4c06c75129e934818377b7827787cf9b
parent6968ea83c5bfb11b725e3ab638a66ff2681ce6f6 (diff)
downloadtxr-f98f2a73750bff9b182c74d073a9c78e5316d7ae.tar.gz
txr-f98f2a73750bff9b182c74d073a9c78e5316d7ae.tar.bz2
txr-f98f2a73750bff9b182c74d073a9c78e5316d7ae.zip
matcher: rename @(let) to @(as).
* lisplib.c (match_instantiate): Ensure usr:as is interned. * share/txr/stdlib/match.tl (compile-let-match): Rename to compile-as-match. (compile-match): Remove handling of let symbol; route as symbol to compile-as-match. * tests/011/patmatch.tl: Update all uses of let to as. * txr.1: Updated.
-rw-r--r--lisplib.c2
-rw-r--r--share/txr/stdlib/match.tl4
-rw-r--r--tests/011/patmatch.tl12
-rw-r--r--txr.116
4 files changed, 17 insertions, 17 deletions
diff --git a/lisplib.c b/lisplib.c
index 5927b4e4..60612575 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -870,7 +870,7 @@ static val match_instantiate(val set_fun)
static val match_set_entries(val dlt, val fun)
{
val name_noload[] = {
- lit("all*"),
+ lit("all*"), lit("as"),
nil
};
val name[] = {
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl
index 864401c0..6c57e0b9 100644
--- a/share/txr/stdlib/match.tl
+++ b/share/txr/stdlib/match.tl
@@ -319,7 +319,7 @@
guard-expr ^(and ,*conditions)))
match)))
-(defun compile-let-match (exp obj-var var-list)
+(defun compile-as-match (exp obj-var var-list)
(mac-param-bind *match-form* (op sym pat) exp
(let ((var-match (compile-var-match sym obj-var var-list))
(pat-match (compile-match pat obj-var var-list)))
@@ -488,7 +488,7 @@
(caseq (car exp)
(struct (compile-struct-match exp obj-var var-list))
(require (compile-require-match exp obj-var var-list))
- (let (compile-let-match exp obj-var var-list))
+ (usr:as (compile-as-match exp obj-var var-list))
(all (compile-loop-match exp obj-var var-list))
(usr:all* (compile-loop-match exp obj-var var-list))
(some (compile-loop-match exp obj-var var-list))
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index f5f658ab..f8f6b03f 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -43,7 +43,7 @@
^((,(find-struct-type 'grommet) :grom)
(,(find-struct-type 'widget) :widg)))
-(test (when-match @(let w (@a @b @c)) '(1 2 3) (list w a b c)) ((1 2 3) 1 2 3))
+(test (when-match @(as w (@a @b @c)) '(1 2 3) (list w a b c)) ((1 2 3) 1 2 3))
(test (when-match @(require (+ @a @b) (equal a b)) '(+ z z) (list a b)) (z z))
(test (if-match @(require (+ @a @b) (equal a b)) '(+ y z)
@@ -84,7 +84,7 @@
(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 @(let x @(op <= 10 @1 13)) 11 x) 11)
+(test (when-match @(as x @(op <= 10 @1 13)) 11 x) 11)
(test (when-match (@(evenp) @(oddp x)) '(2 3) x) 3)
(test (when-match @(or @(require @a (oddp a)) @b @c) 2 (list a b c))
@@ -110,17 +110,17 @@
(set *print-circle* t)
-(test (when-match @(let a @(some @a)) '#1=(1 2 #1# 3) :yes) :yes)
+(test (when-match @(as a @(some @a)) '#1=(1 2 #1# 3) :yes) :yes)
-(test (when-match (@a @(let a @(some @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes)
+(test (when-match (@a @(as a @(some @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes)
-(test (when-match (@a @(let a @(or x @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes)
+(test (when-match (@a @(as a @(or x @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes)
(defstruct node ()
left right)
(mlet ((n (lnew node left (new node left n))))
- (test (when-match @(let x @(struct node
+ (test (when-match @(as x @(struct node
left @(struct node left @x)))
n :yes)
:yes))
diff --git a/txr.1 b/txr.1
index 4d47bbe8..10b9bdd1 100644
--- a/txr.1
+++ b/txr.1
@@ -39783,7 +39783,7 @@ or
.code @(and)
pattern operator, those repeated variables denote one variable.
The left-most, or in the case of
-.code @(let)
+.code @(as)
nesting, outermost, occurrence of the variable binds to the corresponding
element of the object. The remaining occurrences of the variable must
correspond to objects which are
@@ -40221,13 +40221,13 @@ operator matching against an association list.
--> (42)
.brev
-.coNP Pattern operator @ let
+.coNP Pattern operator @ as
.synb
-.mets @(let < name << pattern)
+.mets @(as < name << pattern )
.syne
.desc
The
-.code let
+.code as
pattern operator allows the entire object matched by a
.meta pattern
to be bound to a the variable given by
@@ -40243,7 +40243,7 @@ is
.codn nil ,
then no name is bound. Thus
.mono
-.meti @(let nil << pattern )
+.meti @(as nil << pattern )
.onom
is equivalent to just
.metn pattern .
@@ -40262,7 +40262,7 @@ as its value.
.verb
;; w captures the entire (1 2 3) list:
- (when-match @(let w (@a @b @c)) '(1 2 3) (list w a b c))
+ (when-match @(as w (@a @b @c)) '(1 2 3) (list w a b c))
-> ((1 2 3) 1 2 3)
.brev
@@ -40569,8 +40569,8 @@ function is capable of being called with exactly one argument.
;; 11 matches, since it is in the 10-13 range
(if-match @(op <= 10 @1 13) 11 :yes :no) -> :yes
- ;; let can be used to capture into a variable
- (when-match @(let x @(op <= 10 @1 13)) 11 x) -> 11
+ ;; 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