summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-16 08:18:24 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-16 08:18:24 -0800
commitf6e4ad98057599c2d5d2cd2ba06d17716d77ea53 (patch)
treeea8712d89e7d4dbde297b6792ea4754b2cd24fb2
parent7c2760b2c2f5690b75b9cfe077cde6a2e8aa6898 (diff)
downloadtxr-f6e4ad98057599c2d5d2cd2ba06d17716d77ea53.tar.gz
txr-f6e4ad98057599c2d5d2cd2ba06d17716d77ea53.tar.bz2
txr-f6e4ad98057599c2d5d2cd2ba06d17716d77ea53.zip
matcher: add lambda-match and defun-match
* lisplib.c (match_set_entries): New autoload triggers. * share/txr/stdlib/match.tl (lambda-match, defun-match): New macros.
-rw-r--r--lisplib.c1
-rw-r--r--share/txr/stdlib/match.tl10
2 files changed, 11 insertions, 0 deletions
diff --git a/lisplib.c b/lisplib.c
index 38fa4e35..d7a06fcd 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -875,6 +875,7 @@ static val match_set_entries(val dlt, val fun)
};
val name[] = {
lit("when-match"), lit("match-case"), lit("if-match"),
+ lit("lambda-match"), lit("defun-match"),
nil
};
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl
index 695a0310..9648901c 100644
--- a/share/txr/stdlib/match.tl
+++ b/share/txr/stdlib/match.tl
@@ -294,3 +294,13 @@
^(let (,flag ,result)
,*clause-code
,result)))
+
+(defmacro lambda-match (. clauses)
+ (with-gensyms (args)
+ ^(lambda (. ,args)
+ (match-case ,args ,*clauses))))
+
+(defmacro defun-match (name . clauses)
+ (with-gensyms (args)
+ ^(defun ,name (. ,args)
+ (match-case ,args ,*clauses))))