summaryrefslogtreecommitdiffstats
path: root/lisplib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-11 13:25:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-11 13:25:21 -0700
commit284bb3680d566e26bf6d8ceabacb6634442cde55 (patch)
tree81f9c035c1415017c8af0d2d0bcbb503b864dc25 /lisplib.c
parentec3ef435c68af026ddfca6fa312bde18077194b8 (diff)
downloadtxr-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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisplib.c b/lisplib.c
index 81240da3..53898c08 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -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)