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

Avoid type piracy by defining distinct functions #814

Open
martinholters opened this issue Nov 29, 2023 · 1 comment
Open

Avoid type piracy by defining distinct functions #814

martinholters opened this issue Nov 29, 2023 · 1 comment

Comments

@martinholters
Copy link
Member

As argued by @KristofferC ion #811 (comment) (and I tend to agree), Compat should not commit type piracy by adding methods to Base functions for Base types, but rather define distinct functions of the same name, so that usage needs to be explicit opt-in (by qualification or explicitly named using).

This is different from how we used to do it, by I think it's worthwhile.

If we agree to do it this way, we should start by applying this rule to any new features. I'm not sure we should also go to the trouble of deprecating the old style in favor of the new style for existing features. Anyway, this likely warrants some discussion before setting anything in motion.

@martinholters
Copy link
Member Author

One issue here is that getting rid of old stuff becomes slightly more annoying. Let me explain with the very simple

Compat.jl/src/Compat.jl

Lines 801 to 803 in 8819abe

if VERSION < v"1.9.0-DEV.461"
Base.VersionNumber(v::VersionNumber) = v
end

Wtih the style proposed here, this would become

if VERSION < v"1.9.0-DEV.461"
    VersionNumber(args...) = Base.VersionNumber(args...)
    VersionNumber(v::VersionNumber) = v
else
    const VersionNumber = Base.VersionNumber
end

And users then do Compat.VersionNumber(x) whenever x is (or at least could be) a VersionNumber. All good. But then, eventually, we drop support for Julia prior to 1.10 in Compat v5.0.0, say. Then what? Keep const VersionNumber = Base.VersionNumber indefinitely? Deprecate it to Base.VersionNumber and remove it in v6? Keep it for v5, deprecate in v6, remove in v7?

We would like people to declare compatibility with v5 asap, as it will be much more light-weight after getting rid of the old stuff, but for packages still supporting older Julia, they would also keep compatibility with v4 and keep using Compat.VersionNumber, because they have to.

For those functions which required the Compat. before, I think we went with the deprecate in v5, remove in v6 scheme. But those were only few. If this now concerns every piece of Compat, the keep in v5 as no-op, deprecate in v6, remove in v7 might be in order.

Opinions?

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

No branches or pull requests

1 participant