I have made a discovery
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 18 18:52:22 PDT 2015
On Sunday, 19 April 2015 at 01:19:47 UTC, Brian Schott wrote:
> If you overload a class's `new`, you are deciding for your
> class's user how it will be allocated.
Without telling them btw. (Well, except the documentation or the
source.) So now, they new it and expect the GC to clean it up
like any other class.... but that invisibly doesn't happen.
Overriding new was totally a misfeature in D and it should go
away.
BTW having new in the language at all I wish wasn't a thing.
Perhaps it was right back in old D1, but not ideal in D2, where
we can easily define a template to do it - which could be easily
swapped out at the usage point and enable all kinds of nice
things.
Of course, we can still define library New!T (and indeed, I think
we should), but the keyword will always have a bit of a
brainspace edge over it...
More information about the Digitalmars-d
mailing list