diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-14 07:48:21 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-14 07:48:21 -0800 |
commit | 10e62124c5c19ccdc9afe14d7586ad0efa500283 (patch) | |
tree | 847cd102dd76c469b7b64e8f6ef046983649f774 /lisplib.c | |
parent | 3fdd7328a2f901db16305827ad664abc7736cd83 (diff) | |
download | txr-10e62124c5c19ccdc9afe14d7586ad0efa500283.tar.gz txr-10e62124c5c19ccdc9afe14d7586ad0efa500283.tar.bz2 txr-10e62124c5c19ccdc9afe14d7586ad0efa500283.zip |
new: structural pattern matching.
* lisplib.c (match_instantiate, match_set_entries): New static
functions.
(lisplib_init): Register autoload using new statics.
* share/txr/stdlib/match.tl: New file.
Diffstat (limited to 'lisplib.c')
-rw-r--r-- | lisplib.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -860,6 +860,23 @@ static val quips_set_entries(val dlt, val fun) return nil; } +static val match_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(scat2(stdlib_path, lit("match"))); + return nil; +} + +static val match_set_entries(val dlt, val fun) +{ + val name[] = { + lit("when-match"), + nil + }; + set_dlt_entries(dlt, name, fun); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -914,6 +931,7 @@ void lisplib_init(void) dlt_register(dl_table, copy_file_instantiate, copy_file_set_entries); dlt_register(dl_table, each_prod_instantiate, each_prod_set_entries); dlt_register(dl_table, quips_instantiate, quips_set_entries); + dlt_register(dl_table, match_instantiate, match_set_entries); reg_fun(intern(lit("try-load"), system_package), func_n1(lisplib_try_load)); } |