Skip to content

Commit b038633

Browse files
committed
Give a deprecation warning
1 parent b9f4db6 commit b038633

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

base/Base.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ using .CoreLogging
377377

378378
include("env.jl")
379379

380-
# functions defined in Random
381-
function rand end
382-
function randn end
383-
384380
# I/O
385381
include("libuv.jl")
386382
include("asyncevent.jl")

base/deprecated.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,9 @@ end
392392
@deprecate permute!!(a, p::AbstractVector{<:Integer}) permute!(a, p) false
393393
@deprecate invpermute!!(a, p::AbstractVector{<:Integer}) invpermute!(a, p) false
394394

395+
# functions defined in Random
396+
function rand end
397+
function randn end
398+
export rand, randn
399+
395400
# END 1.11 deprecations

base/exports.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,6 @@ export
994994
unsafe_store!,
995995
unsafe_swap!,
996996

997-
# implemented in Random module
998-
rand,
999-
randn,
1000-
1001997
# Macros
1002998
# parser internal
1003999
@__FILE__,

base/stubs.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
module Stubs
22

3+
macro stub(old, mod)
4+
dep_message = """: `$old` has been moved to the standard library package `$mod`.
5+
Add `using $mod` to your imports."""
6+
return Expr(:toplevel,
7+
quote
8+
import Base: $old
9+
function $(esc(old))(args...)
10+
Base.depwarn($dep_message, $(QuoteNode(old)))
11+
Base.invoke_in_world($(esc(:delay_initialize))(), $(esc(old)), args...)
12+
end
13+
Base.Docs.getdoc(::typeof($(esc(old)))) = ($(esc(:delay_initialize))(); nothing)
14+
end)
15+
end
16+
317
module Random
18+
import ..Stubs: @stub
419
let Random_PkgID = Base.PkgId(Base.UUID(0x9a3f8284_a2c9_5f02_9a11_845980a1fd5c), "Random")
520
RANDOM_MODULE_REF = Ref{Module}()
621

@@ -12,20 +27,10 @@ module Random
1227
return ccall(:jl_module_world, Csize_t, (Any,), RANDOM_MODULE_REF[])
1328
end
1429
end
15-
16-
import Base: rand, randn
17-
function rand(args...)
18-
Base.invoke_in_world(delay_initialize(), rand, args...)
19-
end
20-
21-
function randn(args...)
22-
Base.invoke_in_world(delay_initialize(), randn, args...)
23-
end
30+
@stub rand Random
31+
@stub randn Random
2432
end
2533

26-
Base.Docs.getdoc(::typeof(Base.rand)) = (Random.delay_initialize(); nothing)
27-
Base.Docs.getdoc(::typeof(Base.randn)) = (Random.delay_initialize(); nothing)
28-
2934
function delete_stubs(mod)
3035
for name in names(mod, imported=true)
3136
if name == :delay_initialize

0 commit comments

Comments
 (0)