On Thu Jan 12 17:26:42 2012, xdaveg@gmail.com wrote: > 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" My question is: Why is it unsafe at all to create or delete things from a hash that is being iterated? There have been at least three fixes to the deletion code since 5.14. Could it have anything to do with those? -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=47948Thread Previous | Thread Next