[swift-evolution] Proposal: Weak Native Swift Containers
rileytestut at gmail.com
Thu Dec 10 19:51:28 CST 2015
FWIW, I don’t think it was directly tied to being unable to support weak references to protocol types, but rather was a side-effect (I know I had to change it from “protocol TestProtocol: class” to “protocol TestProtocol: AnyObject” to satisfy some of the compiler errors, but doing that still preventing me from using the protocol directly in certain situations). However, I can no longer reproduce the issue, so it’s possible it was a bug in Swift that has been subsequently fixed.
> On Dec 10, 2015, at 5:27 PM, Chris Lattner <clattner at apple.com> wrote:
>> On Dec 10, 2015, at 4:08 PM, John McCall via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Dec 10, 2015, at 3:31 PM, Riley Testut via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> Using box types solves the portability problems, but it still means O(n) access for clients who want to access the non-boxed values directly. Additionally, these objects aren’t automatically removed from the collection when their values are nil-ed out, which is unfortunate.
>>> Side note: this is the route I originally tried to take, but unfortunately the Swift doesn’t work well with weak references to protocol types…
>> Really? Please file a bug about this; I’ve been working in this area recently.
> It should work with protocols, but they must be class bound.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution