More radical ideas about gc and reference counting

Nick Sabalausky via Digitalmars-d digitalmars-d at puremagic.com
Sat May 3 19:44:39 PDT 2014


On 5/3/2014 6:44 PM, Andrei Alexandrescu wrote:
> On 5/3/14, 12:40 PM, Walter Bright wrote:
>> On 5/1/2014 7:59 AM, Andrei Alexandrescu wrote:
>>> If a class has at least one member with a
>>> destructor, the compiler might need to generate a destructor for the
>>> class.
>>
>> And in fact that's what dmd does.
>
> Which suggests a simple solution for calling destructors for structs and
> arrays:
>
> * Lower new for structs to return:
>
> new S;
> ->
> return &(new class { S member; }).member;
>
> * Lower array construction similarly.
>
> Then voila, the anonymous classes will destroy structs and arrays
> appropriately.
>

Uhh, but doesn't this completely break as soon as class dtors go away?



More information about the Digitalmars-d mailing list