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

Make ranges have a default step of 1 #10813

Open
josevalim opened this issue Mar 25, 2021 · 4 comments
Open

Make ranges have a default step of 1 #10813

josevalim opened this issue Mar 25, 2021 · 4 comments

Comments

@josevalim
Copy link
Member

Today ranges without an explicit step have their step inferred based on start..stop, but instead we should default to always be 1. Given this is a breaking change, it has to be assigned to Elixir v2.0 (which is still not planned nor scheduled).

The goal is to deprecate most of those cases early on, to avoid surprises down the road. We should also consider adding a elixir --future flag that allows developers to run and compile their codebase with these changes early on.

@josevalim josevalim added this to the v2.0.0 milestone Mar 25, 2021
@michalmuskala
Copy link
Member

Would an alternative be to consider a scheme asimilar to Rust editions? Given this would be a pure compile-time change it would be possible to control this behaviour in the compiler, keeping full runtime compatibility, and importantly allow code with old & new behaviour to live together, making the migration much easier.

@josevalim
Copy link
Member Author

The change also happens at runtime if you are calling Range.new. That's why I thought a flag is a good approach: you either run everything with the flag, or everything without the flag, and Mix should check the flag to give you different builds. The only real use is to see if your app will run fine on Elixir v2.0 (which is still a long time ahead).

@Benjamin-Philip
Copy link

Are PRs welcome ?

@josevalim
Copy link
Member Author

No for this one. :) As mentioned in the description:

Given this is a breaking change, it has to be assigned to Elixir v2.0 (which is still not planned nor scheduled).

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

No branches or pull requests

3 participants