On Tue, Apr 23, 2013 at 12:12 AM, Andy Wingo <[email protected]> wrote: > On Tue 23 Apr 2013 01:31, "Tab Atkins Jr." <[email protected]> writes: >> On Mon, Apr 22, 2013 at 2:45 PM, Sam Tobin-Hochstadt <[email protected]> >> wrote: >>> What exactly would be the semantic difference between this and just using >>> 'yield'? >> >> The semantic difference is that 'yield' pauses your execution and >> gives control to the calling code, while 'await' pauses your execution >> and gives control to the promise. Completely different direction of >> control-passing. > > It seems quite unlikely that modern JS implementations would implement > `await' as you describe it. It's relatively easy to suspend computation > in one function frame, which is why we can have nice things like yield. > Suspending multiple function activations is done in some language > environments, but it would be difficult to retrofit into JS > implementations, which is why we can't have nice things like await.
Apologies if I was unclear and caused you to jump to an incorrect conclusion with my wording, but I was referring to what Keven Gadd describes - an async function returns a future that completes when the function does, and this can be realized through a mechanical source-text transformation. (I have no knowledge of how implementations would prefer to realize this, but I'd suspect they'd actually use something like Task/Q's async manager, using some variation on generator semantics internally.) ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

