[swift-evolution] Guaranteed closure execution
Gwendal Roué
gwendal.roue at gmail.com
Mon Feb 1 13:38:44 CST 2016
> Le 1 févr. 2016 à 18:29, Félix Cloutier via swift-evolution <swift-evolution at swift.org> a écrit :
>
> @Gwendal: that's one solution. A third solution would be to enforce that @noescape(once) parameters are executed in parameter order.
>
> Do you have any example of UIKit where a function accepts two closures that could reasonably be marked @noescape(once)?
No Félix, no example in UIKit itself. I was thinking of higher-order applications or library functions that wrap any stateful API. A very artificial example involving UIKit :
func f(@noescape(once) closure1: () -> (), @noescape(once) closure2: () -> (), @noescape(once) closure3: () -> ()) {
closure1()
tableView.beginUpdates()
closure2()
tableView.endUpdates()
closure3()
}
So unless it would be too complex to implement, I would support letting the compiler accept several once closures, without requiring any execution order, and without double-guessing the needs of the developer.
Gwendal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160201/628cb636/attachment-0001.html>
More information about the swift-evolution
mailing list