[Dlang-study] [lifetime] Few root decisions to take on RC classes

Andrei Alexandrescu andrei at erdani.com
Sun Nov 1 11:28:38 PST 2015


On 11/01/2015 02:16 PM, deadal nix wrote:
> 2015-11-01 6:02 GMT-08:00 Andrei Alexandrescu <andrei at erdani.com
> <mailto:andrei at erdani.com>>:
>
>     On 10/31/2015 11:35 PM, Michel Fortin wrote:
>
>         I think it'd be more important to talk about auto-nulling weak
>         references. That's a general concept that is necessary if you want
>         reference counting to be useful and safe at the same time.
>
>
>     Agreed. We need to put weak pointers in the initial DIP and carry
>     them through.
>
>
> It' doesn't looks like this kind of mechanism should be baked into the
> language. It come with a cost that maybe one doesn't want to pay. Maybe
> one is ok to fallback on the GC on that one. Maybe it is preferable to
> provide several kind of RC. Adn weak reference are just one variation
> one may wish.

After much deliberation and collective experience, C++ chose to support 
weak_ptr as a complement to shared_ptr, in spite of the well-understood 
performance overhead. It is sensible to draw from that experience as 
well; also, I agree with Michel that safety makes it all the more 
important that we design weak pointer support in from day one. -- Andrei


More information about the Dlang-study mailing list