Ranges

kdex kdex at kdex.de
Thu Nov 3 16:56:40 UTC 2016


Agreed. There's no reason why `Array.range` or `[1..10]` couldn't just return a generator
or at least something that extends a generator, though. I wonder if it's viable to implement
something akin to `.length` on ranges, which could be natural numbers or `Infinity`.

As for numbers, I don't see any issues. One issue that came up in the original thread was
that string ranges may need a better definition, as ["A".."C"] might not necessarily transpile
to be a generator that yields "A", "B" and "C".

On Thursday, November 3, 2016 4:46:03 PM CET Isiah Meadows wrote:
> I'll note, just for clarity, that Scala's `1 to 10` is technically just a
> normal method call equivalent to `(1).to(10)`, with optional parentheses
> removed.
> 
> Also, I'd prefer this to be a generator instead, so infinite ranges are
> also possible, and so it doesn't have to be eager.
> 
> On Thu, Nov 3, 2016, 11:52 Hikaru Nakashima <oao.hikaru.oao at gmail.com>
> wrote:
> 
> > How about this
> >
> > ```
> > for ( i of Array.range(1, 10) ) { ... }
> > // OR
> > for ( i of [1..10] )  { ... }
> > ```
> >
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
> 


More information about the es-discuss mailing list