diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-11 13:25:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-11 13:25:21 -0700 |
commit | 284bb3680d566e26bf6d8ceabacb6634442cde55 (patch) | |
tree | 81f9c035c1415017c8af0d2d0bcbb503b864dc25 /lisplib.c | |
parent | ec3ef435c68af026ddfca6fa312bde18077194b8 (diff) | |
download | txr-284bb3680d566e26bf6d8ceabacb6634442cde55.tar.gz txr-284bb3680d566e26bf6d8ceabacb6634442cde55.tar.bz2 txr-284bb3680d566e26bf6d8ceabacb6634442cde55.zip |
Hash table iterators exposed, with new macro.
* eval.c (eval_init): Register hash-begin and hash-next intrinsics.
* lisplib.c (hash_set_entries, hash_instantiate): New static functions.
(lisplib_init): Register new tables in dl_table.
* share/txr/stdlib/hash.tl: New file.
* txr.1: Document with-hash-iter macro.
Diffstat (limited to 'lisplib.c')
-rw-r--r-- | lisplib.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -214,6 +214,20 @@ static val with_stream_instantiate(val set_fun) return nil; } +static val hash_set_entries(val dlt, val fun) +{ + val name[] = { lit("with-hash-table-iter"), nil }; + set_dlt_entries(dlt, name, fun); + return nil; +} + +static val hash_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(format(nil, lit("~a/hash.tl"), stdlib_path, nao)); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -233,6 +247,7 @@ void lisplib_init(void) dlt_register(dl_table, path_test_instantiate, path_test_set_entries); dlt_register(dl_table, struct_instantiate, struct_set_entries); dlt_register(dl_table, with_stream_instantiate, with_stream_set_entries); + dlt_register(dl_table, hash_instantiate, hash_set_entries); } val lisplib_try_load(val sym) |