[swift-evolution] Wanted: syntactic sugar for [weak self] callbacks

Félix Cloutier felixcca at yahoo.ca
Tue Feb 2 02:02:04 CST 2016


Hi Kurt,

I believe that this is currently being discussed in "the bind thread <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160201/008649.html>".

Félix

> Le 1 févr. 2016 à 18:40:18, Kurt Werle via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> The pattern
> 
> someObject.callBack() { [weak self] in
>   if let me = self {
>     me.doSomething()
>     ...
>   }
> }
> 
> and friends (guard, etc) are pretty common.  I'd love to have some sugar for that - maybe "firm"
> 
> someObject.callBack() { [firm self] in
>   self.doSomething()
>   ...
> }
> 
> where firm guarantees that the named variable[s] won't be nil - if they are, the block is skipped.
> 
> I think this would make the language easier to use (skipping the complexities/distinction between weak/unowned), more concise, and generally more pleasant.
> 
> Thoughts?
> 
> Thanks,
> Kurt
> -- 
> kurt at CircleW.org
> http://www.CircleW.org/kurt/ <http://www.circlew.org/kurt/>
> _______________________________________________
> 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/20160202/cd313e93/attachment.html>


More information about the swift-evolution mailing list