> On Jul 25, 2016, at 8:47 PM, Chris Lattner via swift-evolution
> <[email protected]> wrote:
>
> Proposal Link:
> https://github.com/apple/swift-evolution/blob/master/proposals/0125-remove-nonobjectivecbase.md
>
> The review of "SE-0125: Remove NonObjectiveCBase and isUniquelyReferenced"
> ran from Active review July 19...22. The proposal has been *accepted*.
>
> This proposal had significant community feedback to help refine and improve
> its design, and Arnold has incorporated that into his v2 of the proposal.
> The core team agrees the new revision is a good design.
A minor quibble with the documentation in the revised version:
> /// Returns `true` iff `object` is class instance with a single strong
> /// reference.
> ///
> /// * Does *not* modify `object`; the use of `inout` is an
> /// implementation artifact.
> /// * Weak references do not affect the result of this function.
> ///
> /// Useful for implementing the copy-on-write optimization for the
> /// deep storage of value types:
> ///
> /// mutating func modifyMe(_ arg: X) {
> /// if isKnownUniquelyReferenced(&myStorage) {
> /// myStorage.modifyInPlace(arg)
> /// }
> /// else {
> /// myStorage = self.createModified(myStorage, arg)
> /// }
> /// }
> public func isKnownUniquelyReferenced<T : AnyObject>(_ object: inout T) ->
> Bool
> public func isKnownUniquelyReferenced<T : AnyObject>(_ object: inout T?) ->
> Bool
Just to be crystal clear about its behavior, I would add a third bullet point
to the list:
/// * Implementation limits may cause this function to always return
/// `false` for some objects, even if they actually are uniquely referenced.
/// It will never return `true` for an object with multiple strong references.
Or perhaps simply:
/// * This function may return false negatives, but never false positives.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution