More radical ideas about gc and reference counting
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 3 15:44:03 PDT 2014
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.
Andrei
More information about the Digitalmars-d
mailing list