I pitch this hoping to provoke a lively discussion to improve the ergonomics of the Swift concurrency.
// Given
func f () async -> Int {...}
func g () async -> Int {...}
func h () async -> Int {...}
// Declare async variables u, v, and w
async let u = f()
async let v = g()
async let w = h()
// Suspend until they all become available
let uvw = await [u, v, w]
// Use them
...
It would be really good to access the value of each variable as they become available.
For example:
await {
case let x = u
// use x
case let y = v
// use y
case let z = w
// use x
case timeout 30
// cancel took to long
break
}
// timeout or all finished
or
await {
case let u = f()
// use u
case let v = g()
// use v
case let w = h()
// use h
case timeout 30
// cancel, took to long
break
}
// timeout or all finished
What do you think?