3 ms·
The async block syntax would be nice, and probably far more explicit. I think with the `return alpha + beta + gamma` the idea is that within a scope, everythin
by ben509 7y ago
The async block syntax would be nice, and probably far more explicit.
I think with the `return alpha + beta + gamma` the idea is that within a scope, everything is done as late as possible, but you can't leave a scope without all results.
Thus, if the code is expanded as:
alpha = run_a()
beta = run_b()
gamma = run_c()
a_plus_b = plus(alpha, beta)
sum = plus(a_plus_b, gamma)
return sum
In that case, the compiler has to determine a partial ordering:
a_plus_b <- run_a, run_b
sum <- a_plus_b, run_c
Thus it can generate:
await gather(run_a, run_b, run_c)
await plus(alpha, beta)
await plus(a_plus_b, gamma)
And presumably you can detect pure subroutine / primitive invocations.
And there would be other hard points where tasks must be fully awaited; e.g. loops wouldn't be able to leak tasks.