Skip to content

Commit

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

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

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

* The generic implementations of `strides(::AbstractArray)` and `stride(::AbstractArray, ::Int)`
have been deprecated. Subtypes of `AbstractArray` that implement the newly introduced strided
Expand Down
1 change: 1 addition & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2818,6 +2818,7 @@ export readandwrite

# PR 25622
@deprecate module_name(m::Module) name(m)
@deprecate Base.function_name(f::Function) name(f)

# 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 @@ -939,11 +939,11 @@ end

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

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

Expand Down
2 changes: 1 addition & 1 deletion base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,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(name(command))

# return true if command should keep active a region
function preserve_active(command::Symbol)
Expand Down
1 change: 0 additions & 1 deletion doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ Base.propertynames
Base.datatype_module
Base.datatype_name
Base.isconst
Base.function_name
Base.function_module(::Function)
Base.function_module(::Any, ::Any)
Base.functionloc(::Any, ::Any)
Expand Down
2 changes: 1 addition & 1 deletion test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,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 name(foo7648) == :foo7648
@test Base.function_module(foo7648, (Any,)) == TestMod7648
@test Base.function_module(foo7648) == TestMod7648
@test Base.function_module(foo7648_nomethods) == TestMod7648
Expand Down

0 comments on commit f317e22

Please sign in to comment.