Next step on reference counting topics

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 06:41:57 PDT 2014


On Monday, 12 May 2014 at 19:00:33 UTC, Andrei Alexandrescu wrote:
> For that I'm proposing we start real work toward a 
> state-of-the-art std.refcounted module. It would include 
> adapters for class, array, and pointer types, and should inform 
> language improvements for qualifiers (i.e. the tail-const 
> problem), copy elision, literals, operators, and such.

We don't have language tools to do it. Main problem with 
implementing reference counted pointers as structs is that you 
are forced to abandon polymorphism:

class A {}
class B : A {}

void foo(RefCounted!A) {}

void main()
{
     RefCounted!B b = new B();
     foo(b); // no way to make it work
}

This severely limits applicability of such library solution, 
especially when it comes to something like exceptions.


More information about the Digitalmars-d mailing list