tc39 / proposal-await-dictionary

A proposal to add Promise.ownProperties(), Promise.fromEntries() to ECMAScript
MIT License
86 stars 4 forks source link

Lexical-based alternative? #20

Closed dead-claudia closed 9 months ago

dead-claudia commented 9 months ago

Maybe something like await let foo = bar, where foo is implicitly awaited on first evaluation or (awkward to spec, easy to implement) function closure reference.

await let foo = one()
await let bar = two(2)
// No suspension yet

let baz = foo /* suspend */ + 1
let wat = foo /* no suspend */ + bar /* suspend */

This sidesteps the whole object API ergonomics problem.

ljharb commented 9 months ago

That is a definite nonstarter, as many delegates have previously objected to async interleaving points that aren't marked by an await (the "suspend" parts are the interleaving points), as well as many delegates including myself objecting to ever having the mere mention of a variable cause side effects (modulo with and global accessors, ofc, which sadly we can't remove)