(poll) Which of the following snippets is invalid? (just reply "all" if all are valid) A: function *foo() { yield; } B: function *foo() { yield undefined; } C: async function foo() { await; } D: async function foo() { await undefined; }
-
Show this thread
-
#spoileralert . . . . . . One might reasonably ask, "why does `yield;` assume `yield undefined`, but `await;` does not?" The answer is, alas, not knowable to us. mere mortals. Tis only for the gods to ponder.6 replies 1 retweet 36 likesShow this thread -
Replying to @getify
Because yield is kind of like return, but await isn't. Just a guess
1 reply 0 retweets 3 likes -
Replying to @DanShappir @getify
yield and return have the same semantics: "yield back to the caller (or in the case of await, the event loop) and return when something happens". I can see an `await` without a value which is used to return control to the event loop in order to yield the cpi to somebody else.
1 reply 0 retweets 0 likes -
Yeah ... no. Promises are micro-tasks - they don't go back to the event loop. await; can be made to be the same as await undefined; for consistency. But it wouldn't be especially useful
2 replies 0 retweets 2 likes -
Replying to @DanShappir @giltayar
Consistency seems to be consistently underrated in programming language design. Very frustrating to those of us who teach and have to field questions about the WHYs of inconsistency.
2 replies 1 retweet 8 likes -
I guess it's challenging to provide 20 years worth of language consistency when you have only 10 days to prepare
#javascript cc@BrendanEich2 replies 0 retweets 1 like -
Although I was original generators champion, TC39 is the source of inconsistency here on await vs yield, not me or anything I did almost 24 years ago. Committee members do think about parallelism of related special forms. Not sure what happened here. Cc:
@bterlson who may recall.1 reply 0 retweets 0 likes
TC39's structure doesn't help. Review happens by same people, in the same meetings, as design and iteration phases. Other web surfaces recently gained outboard review via @w3ctag. Falls heavily on implementers and editors to spot issues in JS.
-
-
Replying to @slightlylate @BrendanEich and
Lack of summary language or formalism also makes comparison harder than it needs to be. That said, I'd weight committee structure as bigger issue.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
& Web Standards TL; Blink API OWNER
Named PWAs w/
DMs open. Tweets my own; press@google.com for official comms.