Skip to content

Make ranges have a default step of 1 #10813

Open

Description

@josevalim

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.

Activity

  1. added this to the v2.0.0 milestone on Mar 25, 2021
  2. michalmuskala commented on Mar 25, 2021

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

  3. josevalim commented on Mar 25, 2021

    @josevalim
    MemberAuthor

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

  4. Benjamin-Philip commented on Apr 26, 2021

    @Benjamin-Philip

    Are PRs welcome ?

  5. josevalim commented on Apr 26, 2021

    @josevalim
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions