Safe reference counting cannot be implemented as a library

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 27 14:26:44 PDT 2015


On Tuesday, 27 October 2015 at 21:20:58 UTC, Andrei Alexandrescu 
wrote:
> On 10/27/2015 04:45 PM, rsw0x wrote:
>> On Tuesday, 27 October 2015 at 20:41:49 UTC, Jonathan M Davis 
>> wrote:
>>> On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote:
>>>>  Why care about this?
>>>>
>>>>  Even Rust doesn't try to solve this problem...because it 
>>>> isn't
>>>> really a problem in practice.
>>>>
>>>>  In c++/rust code you use value/unique types 99.9% of the 
>>>> time, and
>>>> reference counting is only for shared/aliased objects.
>>>>
>>>>
>>>>  Reference counting == rare and unimportant
>>>
>>> Really? I've seen tons of C++ code that's written using smart 
>>> pointers
>>> with objects living on the heap which then get passed around 
>>> all over
>>> the place.
>>
>> if they're using shared_ptr all over the place, they're doing 
>> it wrong.
>> shared_ptr is supposed to be a last resort
>
> This is awesomely Kafkian. So we have no problem after all - 
> just like Go with generics :o). -- Andrei

It has been a great success for Rust, I rarely ever see RC used 
anywhere in Rust code thanks to borrowing. The new C++ core 
guidelines are also heavily based on this cf. *_view types in GSL.

The problem D has is that RC isn't even implemented at library 
level let alone in a state where it's unsafe. IIRC Phobos RC 
doesn't even allow classes.


More information about the Digitalmars-d mailing list