For loop changes

for( number )
Does number repeats of a loop.
for( number as i )
Increments from 0 to number.

Actually workings of for of, for in, and this fors could be without brackets, they don't serve to separate language function as the paranthesis or end of token serve for that here.

What if number is not an integer? What if it's negative? What if it's NaN, or Infinity? What if it's a BigInt, or a proposed Decimal?

This sounds like the syntax equivalent of the Number.range proposal. I would strongly prefer an API-based solution for creating sequences of numbers.


I highly doubt somebody would put number that is not integer as i in for loop.

But maybe 'by' keyword could identify the increment by steps...

No it doesn't ... range creates array, this is proposal for having sugar for i in for loop.

If it is possible, somebody will do it, so the spec would have to define behavior for it.

No, it produces an iterator, which can be used in a for-of loop just like you want.

Well, so it does produces iterator, but for >of< range is not quite good...

loop(5) or for(4) sounds better.

If for value of array sounds good, then for value of range does too, imo.

1 Like

Is there any of your use case doesn't get covered by the range proposal?

1 Like

Maybe the possibility not writing range proposal...

range function which returns iterator is something you don't have to implement, because well, iterator interface is here for that, here I argue for the possibility of not writing range at all.