On Sat, May 11, 2013 at 11:34 PM, Tab Atkins Jr. <[email protected]> wrote: > In addition to what Brendan said about the cost of actually generating > nested arrays in the common case, I don't think this desugaring does > what you want - if you have only a single for-of, you'll just get an > array back out, without a chance to call the custom flatten on it. > > You can't handle this generically, either, because the innermost > for-of is handled as a map rather than a flatMap.
That's intentional. As I wrote, for-of would bind functions of the form A->[TB], not A->TB. > You really do need > to go monadic all the way, and as Brendan said, that's too much cost > for the common case of Arrays. There's a way to accomplish it that wouldn't require creating new arrays, but the flatten operation becomes far less intuitive and loses a lot of the attractiveness of a special syntax. It's essentially inserting a "reified comma" for each loop. > Let's just add do-expressions, or something similar, in the future. > We can leave list comprehensions to their array specialization for > now. OK. -- Mike Stay - [email protected] http://www.cs.auckland.ac.nz/~mike http://reperiendi.wordpress.com _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

