-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What happens with await inside a block param? #28
Comments
Thanks for capturing this, Sam! (BTW it's missing an (Basically in a bake-off between async functions and block params, async functions will win.) |
But I should also add that I think Ron's ideas on the call were promising -- maybe there are solutions involving protocols like the iterator protocol, where we could actually allow propagation of In general, I'm saying that we should aim to get as absolutely close to TCP as possible, or else risk the feature being too non-general and unreliable to succeed. But I think there's reason for optimism that that's solvable! |
I think it'd be unintuitive to have any behaviour other than interrupting both, looking at that code it's how I'd expect it to run. Disallowing await inside the block is an option I suppose, but I think that's a feature people would certainly find useful as per your example. There's more to think about though: async function one (cb) {
const result = await thing();
cb();
}
function two (cb) {
cb();
}
async function three () {
// blocks until the callback it called
await one () {
// you can now block three() here
await thing();
}
// what happens now? you'd expect the block to execute asynchronously
one () {
// ...but then the above behaviour won't work here
await thing();
}
two () {
// ...and it does here
await thing();
}
// this shouldn't execute until all three thing()'s are complete
const result = await thing();
return result;
}
three(); Perhaps functions have an implicit |
let's totally break javascript for the sake of sexyness // base
one(async x => {
await x
})
// block params
one async {
::await
} |
@dherman writes:
Are
await
allowed inside block params? If so, do they interrupt the execution ofreadstuff
orunless
?The text was updated successfully, but these errors were encountered: