On Thu, Jan 12, 2012 at 8:05 PM, James E Keenan via RT <perlbug-followup@perl.org> 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 unsafe. 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 safe" -- DavidThread Previous | Thread Next