Smart pointers instead of GC?

Matthias Einwag matthias.einwag at googlemail.com
Tue Feb 4 10:19:55 PST 2014


> By the way, while this statement was true for initial design, 
> they have recently moved to much more simple model, replacing 
> most of more complicated pointer types with library solutions. 
> I think those who refer to Rust example are more likely to have 
> in mind that new model and your judgement seems to be based on 
> previous one.
In my opinion the new model is even harder. As you can only put 
immutable data in their Gc/Rc structures you end up with things 
like Rc<RefMut<Type>> or Rc<Cell<Type>> and must exactly 
understand what each of those does. For me already the library 
solution in C++ (shared_ptr<Type>) is somewhat annoying to type 
when you compare that to the current D solution or other managed 
languages. Dereferencing these types in Rust is also very hard at 
the moment, but they plan do get it easier.

Freely mixing ARC and GC is also not that easy in my opinion: As 
soon as you have a garbage collected object anywhere in your 
object hierarchy basically anything beneath that will be also 
"garbage collected" - in the sense of only deallocated when the 
GC runs. And if you used RAII semantics in some of your ARC 
managed objects you might wonder why their resources are not 
immediatly releasd, but also when the GC runs.


More information about the Digitalmars-d mailing list