develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl #47948] [documentation] Hash::Util::FieldHash

Thread Previous | Thread Next
David Golden
January 12, 2012 17:26
Re: [perl #47948] [documentation] Hash::Util::FieldHash
Message ID:
On Thu, Jan 12, 2012 at 8:05 PM, James E Keenan via RT
<> wrote:
>> Assuming MJD is correct and the implementation of hashes in 5.10.0
>> hasn't changed this behaviour (it was current at 5.8.8) the
>> documentation should warn about *creating* objects whilst iterating
>> over
>> fields.
> p5p list:  Does the OP's contention about the documentation have merit?
>  If so, what is to be done?

MJD only states that deleting the current hash entry while iterating
with each() is safe.  The problem with fieldhashes is that the
destruction of an inside-out object with data stored in the hash will
delete the corresponding key.  That is an *extra* restriction over
what MJD points out.  It should be safe to destroy the object
corresponding to the key returned by each, as that is just like
deleting the hash entry for that key.  The concern in the
documentation is avoiding code that destroys *other* objects
referenced in the hash, which is tantamount to deleting keys, which is

In other words, "not only do you have to not add/delete keys during
iteration, you have to not add/delete objects that store data in the
hash as well -- except for deleting the current key/object, which is

-- David

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About