Smart pointers instead of GC?

Frank Bauer y at z.com
Sat Feb 1 18:59:17 PST 2014


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).


More information about the Digitalmars-d mailing list