Questions/issues regarding generators
rossberg at google.com
Thu Mar 7 22:54:37 PST 2013
On 7 March 2013 21:58, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> I think the meaning of @@iterator would be clearer if it was named
> asIterator. obj.asIterator()/obj[@@iterator]]() is a request to provide an
> iterator which may be either. obj itself or a new object that provides
> default iteration behavior for obj.
I don't think that renaming solves anything, you still want a useful
contract. (And I would actually have issues with the name asIterator
for something that _is_ a factory in all normal cases.)
> Or, define @@terator such that it return this only on its first call and any
> subsequent @@iterator calls to that object does a clone (if possible). The
> place this would fall down is when an iterator object is passed as a
> parameter down through a chain of calls that do a @@iterator coercion at
> each step of the chain.
Hm, what would be the advantage of that? The semantic fragility it
implies is even worse than for the status quo.
More information about the es-discuss