SRFI-69 appears to provide no guarantee of safety, so for maximum
portability (including to future implementations) you might want to
iterate manually over a copy of the keys obtained via hash-table-keys.
Obviously this is wasteful for large hashes, and I'm sure that's why
you're asking in the first place. :)
On 3/5/07, Graham Fawcett <address@hidden> wrote:
Hi folks,
Is it safe to delete keys hash-table from within a hash-table-walk
procedure? E.g.
(hash-table-walk my-hash-table
(lambda (k v)
(when (bad? v)
(hash-table-delete! my-hash-table k))))
If I'm reading the implementation correctly, it's safe, since a
deletion does not change the length of the storage vector, and the
tail of the current bucket-list (after the deleted item) is preserved
--- meaning that the iteration over the vector will not be
compromised, and neither will the iteration over any bucket-list.
Still, I thought I might get a second opinion. :-)
Thanks,
Graham
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users