Memory Corruption with AAs
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Apr 3 20:21:48 PDT 2010
On 04/02/2010 03:53 PM, Walter Bright wrote:
> dsimcha wrote:
>> I almost never do this with any data structure other
>> than an array because, even if it works for now, I consider it a horrible
>> violation of encapsulation because you're relying on the details of
>> how the data
>> structure manipulates memory. This is also why, when I designed RandAA
>> I didn't
>> see this as an issue until you pointed it out to me.
>
> Andrei is working on the design of the D collection class library. After
> much thought and research, he finally came to the conclusion that a
> collection class should not allow the address of a member to be taken. I
> think his reasoning on the issue is pretty sound, and is consistent with
> your take on it.
I wouldn't call it research, but I agonized a fair amount over it. I
think Phobos containers will all use malloc, realloc, and free for their
own storage, while still being safe.
Andrei
More information about the Digitalmars-d
mailing list