>> 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,
> 
> Then why did you use it, if you don't mind my asking?  What is it supposed to 
> mean in this context?

I suppose I'm struggling with the fact that there's clearly an action taking 
place here (at least in the created case), and yet merely saying 
`createdObject()` or `retrievedObject()` doesn't imply that. Those operations 
sound idempotent, but they're not.

(I kind of want to suggest that retrieving an object through these calls should 
destroy the reference so it can't be used again, but I don't think that fits 
with Swift's mutation model without turning `Unmanaged`/`UnsafeReference` into 
a reference type and adding lots of overhead.)

>> 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.
> 
> Why is that better?

Mainly, because simply saying "release" or "released" is a bit ambiguous to me. 
Are you saying it *has been* released, or are you saying it *needs to be* 
released? I have the same problem with the current 
`takeRetainedValue()`/`takeUnretainedValue()` calls—I'm never sure which one 
I'm supposed to use. I'm hoping that, by stepping up a level and describing the 
semantic you want rather than the operation needed to achieve that semantic, 
this confusion can be cleared up.

I also like that this creates a matched pair of methods. Because they look sort 
of like each other, it's easier to understand that you should call one or the 
other, and to remember them.

> And how does "Retrieved" map onto "Get"?

Not all that cleanly, I admit. "Gotten" would be better, but "get" is an 
irregular verb and I'm a little concerned about programmers who have English as 
a second language. (Plus, I subjectively think it's kind of ugly.)

(One possibility would be to have a single call with an enum parameter, like 
`bridge(.Create)` and `bridge(.Get)`. This would let you use the regular form 
of the verb.)

> Isn't it the users of the functions that don't contain "Create" or "Get" in 
> their names that need the most help?

I think of it more as "treat this like a Create function" or "treat this like a 
Get function".

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to