Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

inconsistent range keywords "from" and "to" #67

Closed
benwbooth opened this Issue · 1 comment

2 participants

Ben Booth Satoshi Murakami
Ben Booth

Currently, the syntax for specifying a range starting from 0 in a for loop is:
i for i from 3

Output:
[ 0, 1, 2 ]

I think it could be more intuitively written this way:
i for i til 3

from should specify the starting value, and til or to should specify the ending value. If from is omitted, it should default to zero. This would be more consistent with specifying a start and stop value:
i for i from 0 til 3

Satoshi Murakami
Owner

This from N sugar originates from range N of Python/Clojure etc., where the shorthand notation specifies the end part rather than start. I agree that it can feel a little strange English-wise.

i for i til 3

I like it. Though a little challenging lexing-wise (to/til is contextual to from right now).

Satoshi Murakami satyr closed this in 9880b47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.