some generator issues

Lars T Hansen lth at acm.org
Mon May 7 03:45:33 PDT 2007


On 4/25/07, Brendan Eich <brendan at mozilla.org> wrote:
> On Apr 24, 2007, at 11:48 AM, Yuh-Ruey Chen wrote:
>
> > I agree. If the current generator is accessed via a static method,
> > then
> > the same should apply to the current function accessor, especially if
> > you intend to deprecate |arguments| in the future. The syntax is
> > rather
> > un-ES like, but if |arguments| is out of the picture, then it's better
> > than introducing a new keyword.
>
> Of course arguments is nowhere near out of the picture, and won't be
> until rest params take over and old code is rewritten or retired --
> which may not happen by any particular date. So I withdraw my
> objection to arguments.generator on account of arguments being
> frowned upon. What's the point of frowning at a brick wall?
>
> The other reason (shadowing of arguments reducing convenience)
> stands, but Generator.current is un-ES-like, I agree -- not in its
> context-free syntax as in its meaning. Function.current instead of
> arguments.callee would be the parallel construction. So unless
> something better pops up, arguments.generator is still winning in my
> view.

In a sense, 'this' is really a keyword shorthand for something we can
think of as 'arguments.receiver'.

I would dearly like to see the arguments object fall into disuse.
Yuh-Ruey writes he likes to use 'arguments.callee' to reference the
current function regardless of its name; now we have use cases for
'arguments.generator'.  IMO this is not moving in the right direction
:-)

Perhaps what we need is a little more syntax without more keywords.
Let 'function' and 'generator' be contextual keywords that can appear
following 'this' without an intervening newline (obviously "function"
is a keyword already).  Then

  this function

names the current function without having to worry about the name of
the function or about looking it up in the nesting scope (ie, it's
like arguments.callee), and

  this generator

names the generator object as the proposed arguments.generator would.

--lars



More information about the Es4-discuss mailing list