Next step on reference counting topics

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 08:56:39 PDT 2014


On Tuesday, 13 May 2014 at 15:11:48 UTC, Andrei Alexandrescu 
wrote:
> On 5/13/14, 6:41 AM, Dicebot wrote:
>> 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.
>
> "alias this" should be of help here. Could you please try it? 
> Thanks! -- Andrei

We don't have multiple alias this to cover all parent classes. 
Also you can't throw struct as an Exception. Also Timon's example.


More information about the Digitalmars-d mailing list