diff --git a/README.md b/README.md index 8ccdb902f..1366e1511 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,9 @@ Currently, the `@compat` macro supports the following syntaxes: * `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of a new function called `parentmodule` ([#25629]). +* `module_name`, `Base.function_name`, and `Base.datatype_name` are now methods of a + new function called `nameof` ([#25622]). + * `find` is now `findall` ([#25545]). * `indmin` and `indmax` are now `argmin` and `argmax`, respectively ([#25654]). @@ -499,6 +502,7 @@ includes this fix. Find the minimum version from there. [#25544]: https://github.com/JuliaLang/julia/issues/25544 [#25545]: https://github.com/JuliaLang/julia/issues/25545 [#25571]: https://github.com/JuliaLang/julia/issues/25571 +[#25622]: https://github.com/JuliaLang/julia/issues/25622 [#25628]: https://github.com/JuliaLang/julia/issues/25628 [#25629]: https://github.com/JuliaLang/julia/issues/25629 [#25654]: https://github.com/JuliaLang/julia/issues/25654 diff --git a/src/Compat.jl b/src/Compat.jl index 40ded6e45..946c7da44 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1469,6 +1469,13 @@ end export codeunits, ncodeunits end +@static if !isdefined(Base, :nameof) + nameof(m::Module) = Base.module_name(m) + nameof(f::Function) = Base.function_name(f) + nameof(t::Union{DataType,UnionAll}) = Base.datatype_name(t) + export nameof +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 94e7082ef..923ac3f0a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1236,6 +1236,12 @@ end @test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) @test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) +# 0.7.0-DEV.3539 +@test nameof(Compat.Sys) == :Sys +@test nameof(sin) == :sin +@test nameof(Float64) == :Float64 +@test nameof(Array) == :Array + # 0.7.0-DEV.3382 module TestLibdl using Compat