From: V.Ch.
Subject: Removing hash entries during maphash
Date: 
Message-ID: <d84ral$132h$1@gavrilo.mtu.ru>
Is it ok to remove hash table entries during maphash? For instance, is 
it guaranteed that the following functions will work as expected:

(defun delete-odds (ht)
   (maphash (lambda (k v)
              (when (oddp k) (remhash k ht))) ht)
   ht)

?

From: Lars Rune Nøstdal
Subject: Re: Removing hash entries during maphash
Date: 
Message-ID: <pan.2005.06.07.21.05.22.567008@gmail.com>
On Tue, 07 Jun 2005 23:08:35 +0400, V.Ch. wrote:

> Is it ok to remove hash table entries during maphash? For instance, is 
> it guaranteed that the following functions will work as expected:
> 
> (defun delete-odds (ht)
>    (maphash (lambda (k v)
>               (when (oddp k) (remhash k ht))) ht)
>    ht)
> 
> ?

http://www.lispworks.com/documentation/HyperSpec/Body/03_f.htm

-- 
mvh,
Lars Rune Nøstdal
http://lars.nostdal.org/
From: Lars Rune Nøstdal
Subject: Re: Removing hash entries during maphash
Date: 
Message-ID: <pan.2005.06.07.21.07.38.729473@gmail.com>
On Tue, 07 Jun 2005 23:05:24 +0200, Lars Rune Nøstdal wrote:

> On Tue, 07 Jun 2005 23:08:35 +0400, V.Ch. wrote:
> 
>> Is it ok to remove hash table entries during maphash? For instance, is 
>> it guaranteed that the following functions will work as expected:
>> 
>> (defun delete-odds (ht)
>>    (maphash (lambda (k v)
>>               (when (oddp k) (remhash k ht))) ht)
>>    ht)
>> 
>> ?
> 
> http://www.lispworks.com/documentation/HyperSpec/Body/03_f.htm

Oh, and this also talks about this:

http://www.lispworks.com/documentation/HyperSpec/Body/f_maphas.htm

"The consequences are unspecified if any attempt is made to add or remove
an entry from the hash-table while a maphash is in progress, with two
exceptions: the function can use can use setf of gethash to change the
value part of the entry currently being processed, or it can use remhash
to remove that entry."

-- 
mvh,
Lars Rune Nøstdal
http://lars.nostdal.org/