-
Notifications
You must be signed in to change notification settings - Fork 44
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
Comments
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. |
I like the idea of a more intuitive function, but I do not like the idea of
students learning range() in a way which is wrong once they move on from
WoofJS to another programming language. Sounds like a formula for confusion
and off by one errors!
Why not just leave range() the way it is now ( range(0, 5) results in [0,
1, 2, 3, 4] ) and make a different function that does the more
intuitive behavior? Perhaps we can call this new function *sequence()* unless
anyone has a better name?
That solves the issue of backwards compatibility because range() is left
unchanged, but sequence() is more intuitive to use. And students who do use
range() won't leave WoofJS and be confused by range() in other languages.
…On Mon, May 25, 2020 at 1:46 PM Steve Krouse ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#582 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACA2A2LSH4AWRCVVXBLCHWTRTKVITANCNFSM4NG6UU6A>
.
|
Good compromise! |
Currently,
range()
follows the conventions of other languages, whererange(0,5)
returns[0,1,2,3,4]
. This makes sense mainly becauserange(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 sayrange(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 1811The text was updated successfully, but these errors were encountered: