Bish for loop bounds are inclusive
tdenniston opened this issue · 2 comments
Currently, the following bish script:
for (i in 0 .. 10) {
print("$i ");
}
will print all numbers from 0 to 10, inclusive. The usual behavior of ranges such as these is that the lower bound is inclusive, but the upper bound is exclusive. Bish should probably match this expectation.
You can perhaps take a page from swift:
http://www.notesfromandy.com/2014/07/30/swifts-range-operators/
official apple docs on this:
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html#//apple_ref/doc/uid/TP40014097-CH6-ID73
so both .. and ...
Thanks for the pointer to that. I'm not sure how I feel about ..<
as an operator though. I also like their compromise of no semicolons but explicit blocks with curly braces. Looks like I'll have to take a closer look at Swift to see what other ideas I can borrow.