I am really trying to say as politely as I can!
I am sorry but I don’t think it is proper way how we do deprecation!
From julia/base/deprecated.jl
:
macro deprecate_moved(old, new, export_old=true, default_package=false)
eold = esc(old)
return Expr(:toplevel,
default_package ? :(function $eold(args...; kwargs...)
error($eold, " has been moved to the standard library package ", $new, ".\n",
"Restart Julia and then run `using ", $new, "` to load it.")
end) :
:(function $eold(args...; kwargs...)
error($eold, " has been moved to the package ", $new, ".jl.\n",
"Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n",
"and then run `using ", $new, "` to load it.")
end),
export_old ? Expr(:export, eold) : nothing,
Expr(:call, :deprecate, __module__, Expr(:quote, old), 2))
end
It is bad enough to return error during deprecation phase, but also if we try something from:
# Special functions have been moved to a package
for f in (:airyai, :airyaiprime, :airybi, :airybiprime, :airyaix, :airyaiprimex, :airybix, :airybiprimex,
:besselh, :besselhx, :besseli, :besselix, :besselj, :besselj0, :besselj1, :besseljx, :besselk,
:besselkx, :bessely, :bessely0, :bessely1, :besselyx,
:dawson, :erf, :erfc, :erfcinv, :erfcx, :erfi, :erfinv,
:eta, :zeta, :digamma, :invdigamma, :polygamma, :trigamma,
:hankelh1, :hankelh1x, :hankelh2, :hankelh2x,
:airy, :airyx, :airyprime)
@eval @deprecate_moved $f "SpecialFunctions"
end
for example:
julia> zeta(0)
ERROR: Base.zeta has been moved to the package SpecialFunctions.jl.
Run `Pkg.add("SpecialFunctions")` to install it, restart Julia,
and then run `using SpecialFunctions` to load it.
it tell us to run Pkg.add
also in case we have SpecialFunctions
installed.
And why we need to restart Julia? Couldn’t using Unicode
redefine Base.uppercase
during deprecation period as we can see below?
julia> uppercase("abc")
ERROR: Base.uppercase has been moved to the standard library package Unicode.
Restart Julia and then run `using Unicode` to load it.
Stacktrace:
[1] error(::Function, ::String, ::String, ::String, ::String, ::String, ::String) at ./error.jl:42
[2] #uppercase#978(::NamedTuple{(),Tuple{}}, ::Function, ::String, ::Vararg{String,N} where N) at ./deprecated.jl:138
[3] uppercase(::String, ::Vararg{String,N} where N) at ./deprecated.jl:138
[4] top-level scope
julia> using Unicode
julia> using Base.uppercase
julia> Base.uppercase(args...; kwargs...) = Unicode.uppercase(args...; kwargs...)
julia> uppercase("abc")
"ABC"
And don’t we need all this newly deprecated functions put in NEWS.md?
Am I missing something?