[swift-evolution] [Draft Proposal] A simplified notation for avoiding the weak/strong dance with closure capture lists

Erica Sadun erica at ericasadun.com
Fri Feb 12 12:34:07 CST 2016


How about 

guard reconstitute self else { return }

-- E

> On Feb 12, 2016, at 11:28 AM, Jason Gregori via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I like Kenny and Kurt's points about handling the majority case and keeping the syntax simpler.
> 
> I feel like most of the time I want to break a retain cycle is for a completion block which returns void. Can we just handle that case and get rid of the else?
> 
> Also, I don't think [guard self] is self explanatory enough. I think weak should be in there so it's much more obvious you are doing the weak/strong dance with self, otherwise it looks like you are guarding against a regular optional being nil.
> 
> So:
> 
> [guard weak self, other]
> _______________________________________________
> 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/20160212/10b139bf/attachment.html>


More information about the swift-evolution mailing list