[swift-evolution] Should explicit `self.` be required when providing method as closure?

Matthew Johnson musical.matthew at mac.com
Sat Mar 4 13:18:12 CST 2017

Sent from my iPad

> On Mar 4, 2017, at 11:35 AM, Charles Srstka via swift-evolution <swift-evolution at swift.org> wrote:
>> On Mar 4, 2017, at 1:09 AM, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
>> I encountered this precise memory leak in my code a few days ago, so I sympathize. A second solution would be to drop function references. I think a core team member suggested it on another thread.
> If I had to guess, I’d surmise that it's probably the single most common memory leak in Swift and modern Objective-C code. What I wish is that it were possible to get rid of implicit captures altogether—instead of just inserting [weak self] when you *don’t* want to capture something strongly, also require [strong self] when you do. Referencing self otherwise causes an error. We’d never get away with it now, though, with the source compatibility promise in place.

Have you seen my guarded closures proposal?  I'm planning to update that to incorporate some additional ideas as soon as I have time.  I'm hoping I can get to this soon and have it reviews for Swift 4.  I think it would help address this problem without breaking compatibility.

> Charles
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170304/ac5e0756/attachment.html>

More information about the swift-evolution mailing list