GC for noobs
Adam D. Ruppe
destructionator at gmail.com
Thu Feb 27 10:37:02 PST 2014
On Thursday, 27 February 2014 at 17:31:57 UTC, Dicebot wrote:
> Isn't it exactly what Phobos RefCounted does?
Yes, though knowing how the implementation works is good for
stuff like interfacing with C where you might need different
acquire/free/add count/release functions than phobos uses.
http://dlang.org/phobos/std_typecons.html#RefCounted
It always uses malloc and free, which isn't always (actually, in
my cases, is rarely ever) what you want.
It is (obviously) possible to write a generic one that takes
aliases (or delegates if you want all refcounted things to have
the same parent type regardless of allocation strategy) for these
functions, I've done that somewhere on the ng or my http server
before too, but phobos doesn't do that either.
The phobos one also doesn't let you wrap classes which is
sometimes useful.
More information about the Digitalmars-d-learn
mailing list