'function *' is not mandatory
till at tillschneidereit.net
Sat Aug 31 18:05:14 PDT 2013
On Sun, Sep 1, 2013 at 2:43 AM, Brendan Eich <brendan at mozilla.com> wrote:
> Lots of constructors/factories out there. An essential (see Aristotle)
> argument for why function* for generator syntax (ignoring trumping reasons
> 1&2) must say why *this* particular factory needs special (a la function*)
> head syntax.
For all non-generator functions, one important assumption for reading them
holds: they always start with the first instruction, and any (potential)
deviations from linear control flow are visible exactly where they (might)
happen. Not so for generators: to understand what invoking a generator
might do, you have to look at all the potential entry points, i.e., all
instructions following a yield in the control flow. If you want to do more
localized reasoning and are interested in a specific invocation, you also
have to reason about which might be the relevant one. Granted, that is
essentially state and any function's control flow can be state-dependent,
so this point might be less important.
Still, having to look at an unknown number of entry points to understand
how control flows through a piece of code seems like something you'll want
to know about. Without searching the code for "yield".
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss