From 07e69928fcab0c5a0e1133fc1f66b18ddd09d408 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 2 Mar 2012 18:26:56 +0100 Subject: hash-set! on weak tables returns the value * libguile/weak-table.h: * libguile/weak-table.c (scm_weak_table_putq_x) (scm_weak_table_remq_x, scm_weak_table_clear_x) (scm_weak_table_for_each): Declare these as returning void instead of SCM. * libguile/hashtab.c (scm_hashq_set_x, scm_hashq_remove_x) (scm_hashv_set_x, scm_hashv_remove_x) (scm_hash_set_x, scm_hash_remove_x) (scm_hashx_set_x, scm_hashx_remove_x): (scm_hash_for_each): For weak tables, have the set! functions return the values, as they used to do. Have remove! functions return #f, indicating the lack of a handle. Shim around for-each to return unspecified, even though that wasn't yet a problem. * test-suite/tests/weaks.test: Add a test. --- libguile/weak-table.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'libguile/weak-table.c') diff --git a/libguile/weak-table.c b/libguile/weak-table.c index 7764f5254..6a3fecd3e 100644 --- a/libguile/weak-table.c +++ b/libguile/weak-table.c @@ -971,24 +971,22 @@ scm_weak_table_refq (SCM table, SCM key, SCM dflt) dflt); } -SCM +void scm_weak_table_putq_x (SCM table, SCM key, SCM value) { scm_c_weak_table_put_x (table, scm_ihashq (key, -1), assq_predicate, SCM_UNPACK_POINTER (key), key, value); - return SCM_UNSPECIFIED; } -SCM +void scm_weak_table_remq_x (SCM table, SCM key) { scm_c_weak_table_remove_x (table, scm_ihashq (key, -1), assq_predicate, SCM_UNPACK_POINTER (key)); - return SCM_UNSPECIFIED; } -SCM +void scm_weak_table_clear_x (SCM table) #define FUNC_NAME "weak-table-clear!" { @@ -1004,8 +1002,6 @@ scm_weak_table_clear_x (SCM table) t->n_items = 0; scm_i_pthread_mutex_unlock (&t->lock); - - return SCM_UNSPECIFIED; } #undef FUNC_NAME @@ -1073,7 +1069,7 @@ for_each_trampoline (void *closure, SCM k, SCM v, SCM seed) return seed; } -SCM +void scm_weak_table_for_each (SCM proc, SCM table) #define FUNC_NAME "weak-table-for-each" { @@ -1081,8 +1077,6 @@ scm_weak_table_for_each (SCM proc, SCM table) SCM_VALIDATE_PROC (1, proc); scm_c_weak_table_fold (for_each_trampoline, SCM_UNPACK_POINTER (proc), SCM_BOOL_F, table); - - return SCM_UNSPECIFIED; } #undef FUNC_NAME -- cgit v1.2.3