Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

range's output should include its second argument #582

Open
hallpell opened this issue May 21, 2020 · 3 comments
Open

range's output should include its second argument #582

hallpell opened this issue May 21, 2020 · 3 comments

Comments

@hallpell
Copy link
Collaborator

Currently, range() follows the conventions of other languages, where range(0,5) returns [0,1,2,3,4]. This makes sense mainly because range(0,array.length) is such a common use case of range in other languages.

However, we don't do very much indexing of arrays in Woof (pretty sure it never shows up in documentation), which makes me less certain that we need to follow this standard for range(). I think it makes more sense to say range(1,5) will count from 1 to 5, and thus return [1,2,3,4,5].

I'm unsure if we actually want this change due to backwards compatibility concerns (it will make most uses of range() in existing projects have one more thing inside them, which will break some things), but is worth considering.

The actual code to change this is trivially easy, making < into <= on 1805 and doing the same for the decreasing for loop at 1811

@stevekrouse
Copy link
Owner

I like the idea of a more intuitive range function.

In terms of backwards compatibility, we've never broken it but I've always thought that if we wanted to, we could save the version of woof (commit hash) with the project (probably when it's created) so we can make breaking changes that won't affect older projects because they will run with the version of woof they were created with.

We'll also have to make sure to show the right version of the documentation as well.

@wendybujalski
Copy link
Collaborator

wendybujalski commented May 25, 2020 via email

@stevekrouse
Copy link
Owner

Good compromise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants