GC vs Resource management.

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon May 5 08:03:04 PDT 2014


On 5/5/14, 3:18 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
> On Sunday, 4 May 2014 at 16:13:23 UTC, Andrei Alexandrescu wrote:
>> On 5/4/14, 4:42 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>>> But I'm afraid your suggestion is unsafe: There also needs to be a way
>>> to guarantee that no references to the scoped object exist when it is
>>> destroyed.
>>
>> Actually, it should be fine to call the destructor, then blast T.init
>> over the object, while keeping the actual memory in the GC. This
>> possible approach has come up a number of times, and I think it has
>> promise. -- Andrei
>
> Then accesses at runtime would still appear to work, but you're actually
> accessing something else than you believe you do. IMO, this is almost as
> bad as silent heap corruption.

Not as bad because memory safety is preserved and the errors are 
reproducible.

> Such code should just be rejected at
> compile-time, if at all possible.

Yah that would be best.


Andrei



More information about the Digitalmars-d mailing list