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

Michel Fortin michel.fortin at michelf.ca
Wed Oct 28 17:35:41 PDT 2015


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.


-- 
Michel Fortin
michel.fortin at michelf.ca
https://michelf.ca




More information about the Dlang-study mailing list