[swift-evolution] Guaranteed closure execution

Félix Cloutier felixcca at yahoo.ca
Wed Feb 3 15:21:44 CST 2016

I updated the proposal to address some concerns. It can be found at: https://github.com/zneak/swift-evolution/blob/master/proposals/00xx-noescape-once.md <https://github.com/zneak/swift-evolution/blob/master/proposals/00xx-noescape-once.md>

Things that changed:

It now says that the closure must be called on code paths where the function throws;
you can have multiple @noescape(once) parameters but they can't make assumptions from one another.

I'm not 100% convinced that forcing a call on code paths that throw is always desirable. I've changed it because Chris's support probably means that the feature has better chances of making it, but I'm not convinced yet. If throwing allows me to return without calling the closure, I can write this:

do {
	let foo: Int
	try withLock(someLock, timeout: 0.5) {
		foo = sharedThing.foo
} catch {
	print("couldn't acquire lock fast enough")

which would be kind of messy if instead, the closure needed a parameter to tell whether the lock was acquired or not when it runs.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160203/c4f3bfce/attachment.html>

More information about the swift-evolution mailing list