17
17
"""
18
18
@deprecate old new [export_old=true]
19
19
20
- Deprecate method `old` and specify the replacement call `new`. Prevent `@deprecate` from
21
- exporting `old` by setting `export_old` to `false`. `@deprecate` defines a new method with the same
22
- signature as `old`.
20
+ Deprecate method `old` and specify the replacement call `new`, defining a new method `old`
21
+ with the specified signature in the process.
22
+
23
+ To prevent `old` from being exported, set `export_old` to `false`.
23
24
24
25
!!! compat "Julia 1.5"
25
26
As of Julia 1.5, functions defined by `@deprecate` do not print warning when `julia`
@@ -34,6 +35,23 @@ old (generic function with 1 method)
34
35
julia> @deprecate old(x) new(x) false
35
36
old (generic function with 1 method)
36
37
```
38
+
39
+ Calls to `@deprecate` without explicit type-annotations will define deprecated methods
40
+ accepting arguments of type `Any`. To restrict deprecation to a specific signature, annotate
41
+ the arguments of `old`. For example,
42
+ ```jldoctest; filter = r"in Main at.*"
43
+ julia> new(x::Int) = x;
44
+
45
+ julia> new(x::Float64) = 2x;
46
+
47
+ julia> @deprecate old(x::Int) new(x);
48
+
49
+ julia> methods(old)
50
+ # 1 method for generic function "old":
51
+ [1] old(x::Int64) in Main at deprecated.jl:70
52
+ ```
53
+ will define and deprecate a method `old(x::Int)` that mirrors `new(x::Int)` but will not
54
+ define nor deprecate the method `old(x::Float64)`.
37
55
"""
38
56
macro deprecate (old, new, export_old= true )
39
57
meta = Expr (:meta , :noinline )
0 commit comments