[swift-evolution] RFC: Proposed rewrite of Unmanaged<T>

Brent Royal-Gordon brent at architechies.com
Sat Dec 19 16:02:02 CST 2015

>>> Also, while unambiguous, it’s a very low-level description of what’s happening, that doesn’t much help the user reading the documentation of a CF function to answer the “which one do I use?” question unless s/he’s already experienced with how to map what it says in that docs onto the use of ADDREF/TAKEREF.
>> I wonder if, instead of talking about retained/unretained, we should talk about whether the call “created" or “retrieved" the object it’s returning. If it created it, the object is +1; if it retrieved it, the object is +0.
> I think I’d need more detail in order to evaluate the idea.  Are you suggesting changing the way some CF functions are documented?  Some concrete examples would certainly help.

CFAttributedString has actually been audited, but pretend it hasn't been...

	let attributedString = CFAttributedStringCreate(nil, anotherString,nil).takeCreatedObject()
	let str = CFAttributedStringGetString(attributedString).takeRetrievedObject()

I'm not a huge fan of the "take" here, but I think this general strategy of trying to say whether the Create Rule or the Get Rule applies is better than trying to make people understand when they should use "released" or not.

Brent Royal-Gordon

More information about the swift-evolution mailing list