You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THIS WHOLE ESSAY IS BROKEN. THE IDEA DOESN'T WORK BECAUSE BY MAKING GENERATOR FUNCTIONS START EXECUTING EAGERLY, THEIR FIRST YIELD SENDS A VALUE THAT THE CALLER CAN'T RECEIVE:
function*foo(){yield"first value"}letg=foo();letit=g.next();// where did "first value" go?
how canceling a cancelation could arise organically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It's important to understand what the purpose of the two abstractions are in order to understand the rest of this essay.
An iterable is a data source, often a mutable one, that can at arbitrary points be iterated over, especially by a for-of loop. An iterable object can have an arbitrary lifetime, and may be long-lived. But iterating over an iterable data structure should be thought of as a relatively short-lived operation, in the sense that the data source should be temporarily frozen during iteration---modifying the iterable data source in the middle of an iteration will generally result in unpredictable behavior.
An iterator produced by an iterable object is therefore a relatively short-lived object, which should not be used once the iteration operation is complete.
Considering the full combinatorics of the space, there are four different independent variables for how to execute top-level code:
HTML vs JS: is the code loaded from an HTML tag or from a JS constructor?
script vs module: is the code executed as an ES(6) Script or Module?
worker vs sync: is the code loaded in a worker or synchronously?
URL vs source: is the code provided as a source string or a URL to an external file?
This leads to 2^4=16 combinations that have to be considered for the design. It doesn't mean authors actually have to deal with all this combinations, since (a) they don't all have to be supported, and (b) some can eventually become old-fashioned legacy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters