http://d.puremagic.com/issues/show_bug.cgi?id=4179
--- Comment #9 from bearophile_h...@eml.cc 2013-07-20 04:05:58 PDT --- (In reply to comment #8) > There are more possible ways to make it safe than this. > > One way is to have a list of current iterations associated with each AA. Any > time an item is removed, any current iterations are also updated. The nodes of > the list can be stored on the stack of aaApply or whatever function does the > "foreach" for AAs. It can be as simple as one pointer in the AA structure, and > a structure with two fields ("current iteration item" / "next list node") on > the stack - this should allow everything to "just work" and have a small > impact > on performance. > > Alternatively, when items are removed from an AA they can be left for the GC > to > collect rather than deleted explicitly, and their "next" pointer can be set to > a magic value indicating that they were deleted (e.g. cast(void*)1). My suggestion was for the foreach to set a boolean flag inside the associative array, and reset it when the foreach ends. Then the AA.delete should look for this flag and throw an exception if it's set. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------