`.toArray()` for all generators

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Aug 29 09:23:10 PDT 2013

plus any time you want you can `GenericPrototype.toArray =
function(){return Array.from(this)};` ... no need to put in specs your C#
flavor, somebody else Python flavor, Ruby, Java, or Haskell ... JS would
look like the tower of babel ^_^

note: it kinda does already in specs V6 and early 7

On Thu, Aug 29, 2013 at 9:01 AM, Forbes Lindesay <forbes at lindesay.co.uk>wrote:

> This all seems fair enough.  My concern is mostly that the
> `blob.method(fn)` syntax seems much easier to get your head around (as
> someone familiar to JavaScript) than the `[for (let x of iter) if (pred(x)
> transf(x)]`.  I always used the traditional syntax for LINQ in C# as well
> (which gave you both options).  Perhaps I'm just too set in my ways though.
>  I'm happy to accept that it's probably easy enough to just rely on
> `Array.from` when you want an array from an iterator.
> -----Original Message-----
> From: Andreas Rossberg [mailto:rossberg at google.com]
> Sent: 29 August 2013 09:56
> To: Forbes Lindesay
> Cc: es-discuss at mozilla.org
> Subject: Re: `.toArray()` for all generators
> On 28 August 2013 17:02, Forbes Lindesay <forbes at lindesay.co.uk> wrote:
> > It would be nice from a readability point of view if
> > `iteratable.toArray()` could always be used as a substitute for
> > `Array.from(iteratable)`.  Is there a way that could be neatly
> > achieved?  It would also be nice if methods like `.map` and `.filter`
> > existed on iteratables.  C# does this via the concept of extension
> > methods, but I wonder whether something similar could be achieved here,
> at least in the case of built in iteratables?
> In addition to what others have already said, note that iterators model
> streams that are not necessarily finite. Hence, a toArray method would not
> generally be well-defined.
> /Andreas
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130829/66dce5b5/attachment.html>

More information about the es-discuss mailing list