Smart pointers instead of GC?
Frank Bauer
y at z.com
Mon Feb 3 14:51:49 PST 2014
Andrei Alexandrescu wrote:
> 2. Work on Phobos to see what can be done about avoiding
> unnecessary allocation. Most likely we'll need to also add a
> @nogc flag.
>
> ...
>
> 4. Work on the core language and druntime to see how to
> seamlessly accommodate alternate GC mechanisms such as
> reference counting.
>
> ...
>
> I thought I made it clear that GC avoidance (which includes
> considering built-in reference counting) is a major focus of
> 2014.
>
> Andrei
My apologies then. Not apologizing for stressing this point over
and over again, though :)
Just to steal some people's thunder: I want the GC to remain in D
as it is. This is not hyperbole or cynicism. I mean it. Having
the GC around to clean up after me for noncritical apps is a
blessing. Adding ARC and owning pointers would make my (and
others) day though.
BTW: Why is most everybody who doesn't like GC obsessed with ARC
pointers? I like them for where they are appropriate. But what
about a simpler owning pointer that frees automatically when it
goes out of scope. It comes at exactly zero runtime cost, just as
a "dumb" pointer. You don't have to drag a reference count around
with you. It is just a pointer in memory. All its semantics are
enforced at compile time. Throw borrowed pointers in the mix,
i.e. references to owning pointers that become "frozen" while
there are outstanding references to them, and you're all set.
I think this would really be necessary (and sufficient!) to get
Rust off your back and whatever half baked language stuff MS is
intentionally leaking these days. At least IMHO and others from
the *vocal minority*.
I'm not quite sure that I understand what you mean by GC
avoidance being a major focus of 2014 though. In the long term,
can I look forward to writing an absolutely, like in 100 %, like
in guaranteed, GC free D app with all of current D's and Phobos'
features if I choose to? Or does it mean: well for the most part
it will avoid the GC, but if you're unlucky the GC might still
kick in if you don't pay attention and when you least expect it?
More information about the Digitalmars-d
mailing list