ES6,ES7,ES8 and beyond. A Proposed Roadmap.

Tab Atkins Jr. jackalmage at gmail.com
Tue Apr 23 10:46:29 PDT 2013


On Tue, Apr 23, 2013 at 12:12 AM, Andy Wingo <wingo at igalia.com> wrote:
> On Tue 23 Apr 2013 01:31, "Tab Atkins Jr." <jackalmage at gmail.com> writes:
>> On Mon, Apr 22, 2013 at 2:45 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> 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


More information about the es-discuss mailing list