On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad
wrote:
On Saturday, 6 February 2016 at 11:09:28 UTC, NX wrote:
On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim
Grøstad wrote:
What makes it impossible to have ref counted classes?
Nothing.
Then why do we need DIP74 ?
I think they aim for compiler optimizations, like ARC on Swift.
But ARC requires all ref counting to be done behind the scene,
so I think it is a bad idea for D to be honest.
And why documentation says RefCounted doesn't work with
classes?
I don't use Phobos much. I think RefCounted creates a wrapper
for an embedded struct or something. Something like struct {
int refcount; T payload; }
Nothing prevents you from creating your own reference counting
mechanism.
reference counting is incredibly slow, DIP74 attempts to
partially amend that in D as it can't be done any other way
besides compiler help.
IIRC, it essentially just allows RC inc/dec to be elided where
possible