mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-26 21:20:30 +02:00
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.
This commit is contained in:
parent
dee4e3ee3c
commit
07e69928fc
4 changed files with 47 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
|||
;;;; weaks.test --- tests guile's weaks -*- scheme -*-
|
||||
;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -232,6 +232,14 @@
|
|||
(hash-set! t "foo" 1)
|
||||
(equal? (hash-ref t "foo") 1)))
|
||||
|
||||
(pass-if "hash-set!, weak key, returns value"
|
||||
(let ((t (make-weak-value-hash-table))
|
||||
(val (string #\f #\o #\o)))
|
||||
(eq? (hashq-set! t "bar" val)
|
||||
(hashv-set! t "bar" val)
|
||||
(hash-set! t "bar" val)
|
||||
val)))
|
||||
|
||||
(pass-if "assoc can do anything"
|
||||
;; Until 1.9.12, as hash table's custom ASSOC procedure was
|
||||
;; called with the GC lock alloc held, which imposed severe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue