diff options
-rw-r--r-- | eval.c | 1 | ||||
-rw-r--r-- | match.c | 5 | ||||
-rw-r--r-- | match.h | 1 | ||||
-rw-r--r-- | stdlib/doc-syms.tl | 1 | ||||
-rw-r--r-- | tests/011/txr-case.txr | 7 | ||||
-rw-r--r-- | txr.1 | 15 |
6 files changed, 29 insertions, 1 deletions
@@ -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)); @@ -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); @@ -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)) @@ -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 |