Skip to content

Commit

Permalink
macro deprecate: docs tweak (#44178)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Feb 15, 2022
1 parent 88edb11 commit 738066c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# is only printed the first time for each call place.

"""
@deprecate old new [ex=true]
@deprecate old new [export_old=true]
Deprecate method `old` and specify the replacement call `new`. Prevent `@deprecate` from
exporting `old` by setting `ex` to `false`. `@deprecate` defines a new method with the same
exporting `old` by setting `export_old` to `false`. `@deprecate` defines a new method with the same
signature as `old`.
!!! compat "Julia 1.5"
Expand All @@ -35,13 +35,13 @@ julia> @deprecate old(x) new(x) false
old (generic function with 1 method)
```
"""
macro deprecate(old, new, ex=true)
macro deprecate(old, new, export_old=true)
meta = Expr(:meta, :noinline)
if isa(old, Symbol)
oldname = Expr(:quote, old)
newname = Expr(:quote, new)
Expr(:toplevel,
ex ? Expr(:export, esc(old)) : nothing,
export_old ? Expr(:export, esc(old)) : nothing,
:(function $(esc(old))(args...)
$meta
depwarn($"`$old` is deprecated, use `$new` instead.", Core.Typeof($(esc(old))).name.mt.name)
Expand All @@ -65,7 +65,7 @@ macro deprecate(old, new, ex=true)
error("invalid usage of @deprecate")
end
Expr(:toplevel,
ex ? Expr(:export, esc(oldsym)) : nothing,
export_old ? Expr(:export, esc(oldsym)) : nothing,
:($(esc(old)) = begin
$meta
depwarn($"`$oldcall` is deprecated, use `$newcall` instead.", Core.Typeof($(esc(oldsym))).name.mt.name)
Expand Down

0 comments on commit 738066c

Please sign in to comment.