summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.c1
-rw-r--r--match.c5
-rw-r--r--match.h1
-rw-r--r--stdlib/doc-syms.tl1
-rw-r--r--tests/011/txr-case.txr7
-rw-r--r--txr.115
6 files changed, 29 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index b7e34f5d..81c7cdca 100644
--- a/eval.c
+++ b/eval.c
@@ -7397,6 +7397,7 @@ void eval_init(void)
reg_fun(intern(lit("abscond*"), system_package), func_n2o(abscond_star, 1));
reg_fun(intern(lit("match-fun"), user_package), func_n4o(match_fun, 2));
+ reg_fun(intern(lit("match-fboundp"), user_package), func_n1(match_fboundp));
reg_fun(intern(lit("source-loc"), user_package), func_n1(source_loc));
reg_fun(intern(lit("source-loc-str"), user_package), func_n2o(source_loc_str, 1));
diff --git a/match.c b/match.c
index e07ab1c1..e2d01b80 100644
--- a/match.c
+++ b/match.c
@@ -5032,6 +5032,11 @@ val match_fun(val name, val args, val input_in, val files_in)
return cons(c.bindings, if3(c.data, cons(c.data, c.data_lineno), t));
}
+val match_fboundp(val name)
+{
+ return tnil(uw_get_func(name));
+}
+
val include(val specline)
{
val spec = cons(specline, nil);
diff --git a/match.h b/match.h
index d92740ea..b697cc0a 100644
--- a/match.h
+++ b/match.h
@@ -34,6 +34,7 @@ val match_expand_keyword_args(val elem);
val match_expand_elem(val elem);
val match_filter(val name, val arg, val other_args);
val match_fun(val name, val args, val input, val files);
+val match_fboundp(val name);
val include(val specline);
val extract(val spec, val filenames, val bindings);
void match_reg_var(val sym);
diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl
index 1148e256..19804e8d 100644
--- a/stdlib/doc-syms.tl
+++ b/stdlib/doc-syms.tl
@@ -1241,6 +1241,7 @@
("match" "N-01BE5C4A")
("match-case" "N-0282196B")
("match-ecase" "N-0282196B")
+ ("match-fboundp" "N-02AF4E8B")
("match-fun" "N-033F766A")
("match-regex" "N-02E3A26F")
("match-regex-right" "N-019430C5")
diff --git a/tests/011/txr-case.txr b/tests/011/txr-case.txr
index aa234ed8..d6d8d788 100644
--- a/tests/011/txr-case.txr
+++ b/tests/011/txr-case.txr
@@ -1,4 +1,5 @@
@(load `@{stdlib}txr-case`)
+@(include "../common")
@(define date (year month day))
@{year /\d\d\d\d/}-@{month /\d\d/}-@{day /\d\d/}
@(end)
@@ -18,4 +19,8 @@ blah
"foo bar"))
(notmatch () (put-line "notexpected"))
- (stuff (y m d a b) (put-line `match: year @y, month @m, day @d, @a:@b`))))
+ (stuff (y m d a b) (put-line `match: year @y, month @m, day @d, @a:@b`)))
+ (mtest
+ (match-fboundp 'notmatch) t
+ (match-fboundp 'stuff) t
+ (match-fboundp 'xyzzy) nil))
diff --git a/txr.1 b/txr.1
index 6ef01d69..2674faeb 100644
--- a/txr.1
+++ b/txr.1
@@ -76047,6 +76047,21 @@ out of the pattern function
.codn foo ;
it is local inside it.
+.coNP Function @ match-fboundp
+.synb
+.mets (match-fboundp << symbol )
+.syne
+.desc
+The
+.code match-fboundp
+function returns
+.code t
+or
+.code nil
+if, respectively,
+.meta symbol
+is the name of an existing pattern function.
+
.coNP Macro @ txr-if
.synb
.mets (txr-if < name <> ( argument *) < input