tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Bish for loop bounds are inclusive #41

Open tdenniston opened 9 years ago

tdenniston commented 9 years ago

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.

digitalsurgeon commented 9 years ago

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 ...

tdenniston commented 9 years ago

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.