[Dlang-study] [lifetime] Initial thoughts on lifetime management

Timon Gehr timon.gehr at gmx.ch
Wed Oct 28 17:47:29 PDT 2015


On 10/29/2015 01:35 AM, Michel Fortin wrote:
> Le 28 oct. 2015 à 18:39, Timon Gehr <timon.gehr at gmx.ch> a écrit :
>
>> Actually, we do not need #references <= count.
>> It's just (#references > 0) -> (count > 0).
>> (The converse should also hold, but then #references has to include cyclic references.)
>
> There's still some value in knowing that the total number of references is 1 and not something higher.
>
> Swift has `isUniquelyReferenced` you can use to implement copy-on-write value types in a thread-safe way.
> I'm not entirely sure why they can guaranty uniqueness for Swift classes; it looks like they can't when
> it comes to Objective-C classes.
>
>

Good point. However, it seems somewhat costly to support for classes 
that don't need it.


More information about the Dlang-study mailing list