11module 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+
317module 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
2432end
2533
26- Base. Docs. getdoc (:: typeof (Base. rand)) = (Random. delay_initialize (); nothing )
27- Base. Docs. getdoc (:: typeof (Base. randn)) = (Random. delay_initialize (); nothing )
28-
2934function delete_stubs (mod)
3035 for name in names (mod, imported= true )
3136 if name == :delay_initialize
0 commit comments