some generator issues
maian330 at gmail.com
Tue May 8 18:09:02 PDT 2007
Lars T Hansen wrote:
> 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.
I like it. What's the operator precedence?
I wonder if this can be extended to iterators in general. Since
generator functions are essentially sugar (albeit really awesome sugar +
send() + close()) for iterators, |this generator| could be generalized
to |this iterator|. Although generator-iterators are different from
normal iterators, they are iterators nonetheless. I can't think of any
use cases of the top of my head, and I'm not sure how it would be done,
considering that iterators are a protocol, not some class (i.e. I'm not
sure how ES can determine |this iterator| when the user calls
iter.next() for a user-defined iterator).
More information about the Es4-discuss