[Issue 4475] Improving the compiler 'in' associative array can return just a bool
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 15 10:06:34 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4475
hsteoh at quickfur.ath.cx changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hsteoh at quickfur.ath.cx
--- Comment #9 from hsteoh at quickfur.ath.cx 2013-08-15 10:06:29 PDT ---
(In reply to comment #8)
[...]
> > aa["a"] = new C();
> > auto c = "a" in aa;
> > aa["b"] = new C();
> > // Using c here is undefined as an element was added to aa
>
> This can't happen if "in" returns a bool.
Actually, that is not undefined. AA's are designed such that inserting new
elements does not invalidate pointers to existing elements. In D, because we
have a GC, even if you *delete* elements from AA's, pointers returned by 'in'
continue to be valid. This holds even in the event of a rehash, because the
pointer points to data in a Slot, and add/remove/rehash only shuffle pointers
in the Slot, it doesn't move the Slot around in memory.
--
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