[Issue 4179] Deleting items from an associative array iterated over
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 29 08:30:32 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4179
Jonathan M Davis <jmdavisProg at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg at gmx.com
--- Comment #4 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-03-29 08:26:59 PDT ---
SafeD refers to memory safety. The current behavior is completely memory safe.
The same could happen with any container whose iterators/ranges are invalidated
by the removal of an element from the container. It would be nice if removing
elements from an AA while looping over it worked, but it's not at all
surprising that it doesn't, and it may not be reasonable to require that it
does. And it's easy enough to get around this. You just save a list of the
items that you want to remove, and then you remove them after you're done
iterating over the AA.
There's nothing unsafe about the current behavior. It may be a bit bug-prone
for the unwary, but this sort of things is normal when dealing with iterators
or ranges. If it were unsafe, it wouldn't be throwing a RangeViolation but
would keep trying to iterate using invalid data and do who-knows-what.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list