[swift-evolution] [swift-evolution-announce] [Review] SE-0125: Remove NonObjectiveCBase and isUniquelyReferenced
brent at architechies.com
Wed Jul 20 05:13:29 CDT 2016
> On Jul 19, 2016, at 11:06 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
> - I find it a little strange to see a mention of Objective-C, and a
> negation in `isUniquelyReferencedNonObjC`. For example, if we get C++
> import, would we need to rename it to
> `isUniquelyReferencedNonObjCAndNonCXX`? I think that is the issue
> with negation. If we want to emphasize that the API will work only
> with Swift types, we can do something
> `isUniquelyReferencedSwiftReference`. But I would probably suggest
> that we just go with just `isUniquelyReferenced` and mention the
> Swift-only requirement in the documentation.
What is the reason that isUniquelyReferenced(_:) doesn't work with Objective-C? It doesn't seem like it'd be difficult to implement—you'd either call -retainCount, or get it from the Objective-C runtime somehow, and then test it against 1—so I assume there's a reason we don't.
I ask because knowing that may help us figure out how to name it. For instance, if the issue is that we can't rely on Objective-C reference counts, we might reverse the sense of the call and name it `mayBeShared(_:)` or `mayHaveOtherReferences(_:)`.
More information about the swift-evolution