'function *' is not mandatory

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Sun Sep 1 13:42:28 PDT 2013

On Sun, Sep 1, 2013 at 7:56 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Jussi Kalliokoski <mailto:jussi.kalliokoski@**gmail.com<jussi.kalliokoski at gmail.com>
>> >
>> September 1, 2013 5:38 AM
>> Sorry if this has been brought up before,
> It has, even in this thread.

My apologies! Ran a quick scan with my eyes and a find for `generator (`
and `generator(` to no results so decided to bring this up after
contemplating it for quite a while now since the topic is relevant.

>  but why `function *` (which looks like a pointer to a function more than
>> a generator
> This is JS, please take off your C/C++ hat :-P.

Sure, but let's not ignore that this syntax already has a special meaning
in the language family JS syntax is heavily based on. Like I asked, why
does it have to be the star? Why not tilde? Or plus? Why take something
that already has a completely different meaning in other languages?

 ) instead of something clearer, e.g. `generator myGenerator () {}`? I see
> the obvious ASI hazard, but this can be mitigated by not allowing unnamed
> generators, e.g. `{ myGenerator: generator _ () {} } `,

This doesn't work in general, it is backward-incompatible. If someone bound
> or assigned to generator in-scope, your proposed change could break
> compatibility -- or else require parsing to depend on name binding.
> foo = generator
> bar()
> {}
> Remember, if there wasn't an error, ASI doesn't apply. Trying to "patch"
> this bad theory with a [no LineTerminator here] restriction to the right of
> 'generator' does not work in the grammar without reserving 'generator' --
> we can't put that restriction to the right of every Identifier on the right
> of every expression production.

Can you elaborate on this, please, I'm confused? Why can't we restrict the
syntax? Unrestricted syntax is why we are having this discussion in the
first place. What's the negative effect of reserving 'generator'? In my
opinion the parser saying "ohmigod" and going back a few cycles when
hitting `generator` is a lot better than humans having to read what we are
going for now. After all, what's the point of programming languages aside
readability? How come is it not OK to disallow the syntax in your example
to be a valid generator, regardless of whether `generator` is defined or
not? What am I missing?

I'm sorry if I'm asking stupid questions, but the only stupid question is
the one left unasked.


> Please stamp this on all inner eyelids so I don't have to repeat it ad
> nauseum. Thanks!
> /be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130901/f096551f/attachment.html>

More information about the es-discuss mailing list