Skip to content

Commit 4006e34

Browse files
committed
Deprecate Base.function_name to a nameof method
1 parent db2148e commit 4006e34

6 files changed

Lines changed: 9 additions & 6 deletions

File tree

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,9 @@ Deprecated or removed
964964

965965
* `findin(a, b)` has been deprecated in favor of `findall(occursin(b), a)` ([#24673]).
966966

967-
* `module_name` has been deprecated in favor of a new, general `nameof` function ([#25622]).
967+
* `module_name` has been deprecated in favor of a new, general `nameof` function. Similarly,
968+
the unexported `Base.function_name` has been deprecated in favor of a `nameof` method
969+
([#25622]).
968970

969971
* The module `Random.dSFMT` is renamed `Random.DSFMT` ([#25567]).
970972

base/deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ export readandwrite
16261626

16271627
# PR #25622
16281628
@deprecate module_name(m::Module) nameof(m)
1629+
@deprecate function_name(f::Function) nameof(f) false
16291630

16301631
# PR #25196
16311632
@deprecate_binding ObjectIdDict IdDict{Any,Any}

base/reflection.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,11 @@ end
10171017

10181018
# function reflection
10191019
"""
1020-
Base.function_name(f::Function) -> Symbol
1020+
nameof(f::Function) -> Symbol
10211021
10221022
Get the name of a generic `Function` as a symbol, or `:anonymous`.
10231023
"""
1024-
function_name(f::Function) = typeof(f).name.mt.name
1024+
nameof(f::Function) = typeof(f).name.mt.name
10251025

10261026
functionloc(m::Core.MethodInstance) = functionloc(m.def)
10271027

doc/src/base/base.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Base.fullname
339339
Base.names
340340
Core.nfields
341341
Base.isconst
342-
Base.function_name
342+
Base.nameof(::Function)
343343
Base.functionloc(::Any, ::Any)
344344
Base.functionloc(::Method)
345345
Base.@functionloc

stdlib/REPL/src/LineEdit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const COMMAND_GROUPS =
219219

220220
const COMMAND_GROUP = Dict(command=>group for (group, commands) in COMMAND_GROUPS for command in commands)
221221
command_group(command::Symbol) = get(COMMAND_GROUP, command, :nogroup)
222-
command_group(command::Function) = command_group(Base.function_name(command))
222+
command_group(command::Function) = command_group(Base.nameof(command))
223223

224224
# return true if command should keep active a region
225225
function preserve_active(command::Symbol)

test/reflection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ let
266266
using .TestMod7648
267267
@test Base.binding_module(@__MODULE__, :a9475) == TestMod7648.TestModSub9475
268268
@test Base.binding_module(@__MODULE__, :c7648) == TestMod7648
269-
@test Base.function_name(foo7648) == :foo7648
269+
@test nameof(foo7648) == :foo7648
270270
@test parentmodule(foo7648, (Any,)) == TestMod7648
271271
@test parentmodule(foo7648) == TestMod7648
272272
@test parentmodule(foo7648_nomethods) == TestMod7648

0 commit comments

Comments
 (0)