JuliaLang / Compat.jl

Compatibility across Julia versions
Other
148 stars 117 forks source link

Always define `range(start, stop)` #642

Closed martinholters closed 5 years ago

martinholters commented 5 years ago

Ref. #640 and https://github.com/JuliaLang/julia/issues/30374#issuecomment-454760918. I aim at implementing option 3 mentioned in the latter, i.e. tag a release after this has been merged, then remove the offending functionality and tag another release.

Downside here is

WARNING: Method definition range(Any, Any) in module Base at range.jl:91 overwritten in module Compat at /home/travis/build/JuliaLang/Compat.jl/src/Compat.jl:1857.
WARNING: Method definition #range(Any, typeof(Base.range), Any, Any) in module Base overwritten in module Compat.

of course.

martinholters commented 5 years ago

Well, the warning could be avoided with

function __init__()
    @eval Base begin
        range(start, stop; kwargs...) = range(start; stop=stop, kwargs...)
    end
end

but that feels so wrong I'm not sure I don't prefer the warning... Better ideas?

martinholters commented 5 years ago

Thinking about this again, it would be nice to deprecate range(start, stop) in the next major version (instead of making it error directly), but then these warnings would be really unfortunate, so I've updated with the @eval Base version.

@ararslan, any comments?

martinholters commented 5 years ago

Barring objections, I think I'll merge this tomorrow. Even if the implementation has flaws (and I'm not saying it has, just that it might), it's still a step forward IMO.