Skip to content

Commit

Permalink
Deprecate Base.function_name to a nameof method
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Jan 22, 2018
1 parent 7991a40 commit 0fa959b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,9 @@ Deprecated or removed

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

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

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

Expand Down
1 change: 1 addition & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@ export readandwrite

# PR #25622
@deprecate module_name(m::Module) nameof(m)
@deprecate function_name(f::Function) nameof(f) false

# PR #25196
@deprecate_binding ObjectIdDict IdDict{Any,Any}
Expand Down
4 changes: 2 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1017,11 +1017,11 @@ end

# function reflection
"""
Base.function_name(f::Function) -> Symbol
nameof(f::Function) -> Symbol
Get the name of a generic `Function` as a symbol, or `:anonymous`.
"""
function_name(f::Function) = typeof(f).name.mt.name
nameof(f::Function) = typeof(f).name.mt.name

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

Expand Down
2 changes: 1 addition & 1 deletion doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Base.fullname
Base.names
Core.nfields
Base.isconst
Base.function_name
Base.nameof(::Function)
Base.functionloc(::Any, ::Any)
Base.functionloc(::Method)
Base.@functionloc
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const COMMAND_GROUPS =

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

# return true if command should keep active a region
function preserve_active(command::Symbol)
Expand Down
2 changes: 1 addition & 1 deletion test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ let
using .TestMod7648
@test Base.binding_module(@__MODULE__, :a9475) == TestMod7648.TestModSub9475
@test Base.binding_module(@__MODULE__, :c7648) == TestMod7648
@test Base.function_name(foo7648) == :foo7648
@test nameof(foo7648) == :foo7648
@test parentmodule(foo7648, (Any,)) == TestMod7648
@test parentmodule(foo7648) == TestMod7648
@test parentmodule(foo7648_nomethods) == TestMod7648
Expand Down

0 comments on commit 0fa959b

Please sign in to comment.