Smart pointers instead of GC?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Feb 1 19:37:40 PST 2014


On 2/1/14, 6:59 PM, Frank Bauer wrote:
> Just to clarify: I would like to have the following pointers. I'll start
> with the GC ones to maybe reach some consensus quicker ;)
>
> 1. GC(T)
> Pointer to a heap allocated T, garbage collected.
>
> 2. ARC(T)
> Reference counted pointer to a heap allocated T, compiler manages
> lifetime automatically via retain/ release.
>
> 3. Owning(T)
> Pointer to a heap allocated T, freed when pointer goes out of scope or
> is reassigned (some special interactions with Borrowed(T) on top of that).
>
> 4. Borrowed(T)
> Pointer to a T, not necessarily heap allocated, has no impact on memory
> allocation/ deallocation of the T whatsoever, if assigned from an
> Owning(T) prevents that owning pointer from being freed or reassigned as
> long as the borrowed pointer is in scope.
>
> Performance, or, should I say, meddling of the compiler and runtime in
> your code, is from worst to best.
>
> We could argue over which pointer concepts would be granted the honor of
> receiving their own D definition syntax (new, ~, @, &, whatever).

Whoa, this won't work without an explosion in language complexity.

Andrei



More information about the Digitalmars-d mailing list