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:
On Tue, 20 Jan 2015 20:51:34 -0500
Steven Schveighoffer via Digitalmars-d <digitalmars-d@puremagic.com>
wrote:

You can always put @nogc on the dtor if you want.
seems that you completely missing my point. (sigh)

Nope, not missing it. The mechanics are there. You just have to
annotate.
that is where you missing it. your answer is like "hey, C has all
mechanics for doing OOP with virtual methods and type checking, you
just have to write the code!"

No, actually it's not. Adding @nogc to a function is as hard as
writing "class" when you want to do OOP.


the whole point of my talk was "free programmer from writing the
obvious and setup some red tapes for beginners".

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.


Actually there's nothing on the documentation about class destructors
[1] that warns about that specific issue of the current (and default) GC.

[1] http://dlang.org/class.html#destructors


I think the docs are in need of updating there. It's not meant to be a secret that you cannot allocate inside a GC collection. I'll try to put together a PR.

-Steve

Reply via email to