forcing "@nogc" on class destructors
aldanor via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 23 05:17:51 PST 2015
On Friday, 23 January 2015 at 13:12:44 UTC, Steven Schveighoffer
wrote:
> On 1/23/15 8:05 AM, Matthias Bentrup wrote:
>> On Friday, 23 January 2015 at 10:53:54 UTC, aldanor wrote:
>>> On Friday, 23 January 2015 at 08:58:11 UTC, Ola Fosheim
>>> Grøstad wrote:
>>>> How about banning GC-allocation of classes with destructors?
>>> Uh... what? ^__^
>>>
>>> Maybe just ban classes altogether then?
>>
>> No, don't ban them, that will break to much code. Just don't
>> execute
>> them. Any application that depends on destructors being called
>> by the GC
>> is broken in 9 out of 10 cases anyway.
>
> This is very wrong.
>
> -Steve
Summing up the arguments in this thread, I think the reasonable
middle ground here would be for a compiler to throw a warning if
dtor doesn't satisfy @nogc. I.e., compiler knows at compile time
that something MAY and probably WILL go wrong; the code as of
current GC implementation is then unsafe which should be reported
to the user. This is much better than just silent obscure memory
exceptions at runtime.
More information about the Digitalmars-d
mailing list