diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-07-23 07:33:49 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-07-23 07:33:49 -0700 |
commit | 594b7bf1f4d88cdc2073cfccdf9b279892537461 (patch) | |
tree | 760bfb2718c26fe66602ce1ea251e4093ec40e0e /lisplib.c | |
parent | d6760da67732419d8043d1fdc43e8081f96ef1f1 (diff) | |
download | txr-594b7bf1f4d88cdc2073cfccdf9b279892537461.tar.gz txr-594b7bf1f4d88cdc2073cfccdf9b279892537461.tar.bz2 txr-594b7bf1f4d88cdc2073cfccdf9b279892537461.zip |
Adding with-resources macro.
* share/txr/stdlib/with-resources.tl: New file.
* lisplib.c (with_resource_set_entries, with_resources_instantiate):
New static functions.
(lisplib_init): Register new functions under dlt_register.
* txr.1: Document with-resources.
Diffstat (limited to 'lisplib.c')
-rw-r--r-- | lisplib.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -126,6 +126,20 @@ static val txr_case_instantiate(val set_fun) return nil; } +static val with_resources_set_entries(val dlt, val fun) +{ + val name[] = { lit("with-resources"), nil }; + set_dlt_entries(dlt, name, fun); + return nil; +} + +static val with_resources_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(format(nil, lit("~a/with-resources.tl"), stdlib_path, nao)); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -141,6 +155,7 @@ void lisplib_init(void) dlt_register(dl_table, ver_instantiate, ver_set_entries); dlt_register(dl_table, ifa_instantiate, ifa_set_entries); dlt_register(dl_table, txr_case_instantiate, txr_case_set_entries); + dlt_register(dl_table, with_resources_instantiate, with_resources_set_entries); } val lisplib_try_load(val sym) |