forcing "@nogc" on class destructors

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 22 03:50:57 PST 2015


On 1/21/15 6:03 PM, Paolo Invernizzi wrote:
> On Wednesday, 21 January 2015 at 20:32:14 UTC, Steven Schveighoffer wrote:
>> On 1/21/15 3:37 AM, Paolo Invernizzi wrote:
>>> On Wednesday, 21 January 2015 at 03:02:53 UTC, Steven Schveighoffer
>>> wrote:
>>>> On 1/20/15 9:04 PM, ketmar via Digitalmars-d wrote:
>>>> If he does it wrong, it gives him a stack trace on where to look. What
>>>> is different here than any other programming error?
>>>
>>> Are you suggesting that newcomers should learn D by discovering it day
>>> by day from stack traces?
>>
>> No, I was saying if something causes an exception/error, it is a
>> programming error, and there just isn't any way for a compiler to
>> prevent people from making *any* mistakes.
>>
>> But calling sometimes-allocating functions inside a dtor that don't
>> allocate when you call them *that* time shouldn't be banned by the
>> compiler.
>
> You can't ban them, either now with an annotated @nogc destructor:
> SetFunctionAttributes.

Right, but the runtime will still catch it if it allocates. I think the 
correct place to check it is where it's checked now.

-Steve



More information about the Digitalmars-d mailing list