GC-proof resource classes
rsw0x via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 29 07:45:40 PDT 2015
On Saturday, 29 August 2015 at 14:32:27 UTC, Timon Gehr wrote:
> On 08/29/2015 04:20 PM, cym13 wrote:
>> On Saturday, 29 August 2015 at 14:17:10 UTC, rsw0x wrote:
>>> On Saturday, 29 August 2015 at 13:14:26 UTC, ponce wrote:
>>>> ...
>>>
>>> All of this could be fixed by not letting the GC call
>>> destructors.
>>> It's a bad, error-prone design to begin with and I guarantee
>>> any
>>> semi-large D program is probably abusing undefined behavior
>>> due to it.
>>
>> After reading all that, I too am convinced that the GC
>> shouldn't call
>> the destructor.
>
> But then classes with destructors shouldn't be allowed to be
> allocated on the GC heap in the first place, which is a PITA as
> well. (Note that classes/arrays can have destructors because
> some component structs have them; structs generally assume that
> their destructors will be called.)
make classes with destructors(and structs allocated via new) have
RC semantics.
More information about the Digitalmars-d
mailing list