Skip to content

Commit f82f82f

Browse files
authored
Merge pull request #25615 from JuliaLang/jb/underscoredeps
remove some underscores
2 parents ae0a3e9 + 6412f06 commit f82f82f

26 files changed

+69
-72
lines changed

base/asyncmap.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ then be a function that must accept a `Vector` of argument tuples and must
2323
return a vector of results. The input vector will have a length of `batch_size` or less.
2424
2525
The following examples highlight execution in different tasks by returning
26-
the `object_id` of the tasks in which the mapping function is executed.
26+
the `objectid` of the tasks in which the mapping function is executed.
2727
2828
First, with `ntasks` undefined, each element is processed in a different task.
2929
```
30-
julia> tskoid() = object_id(current_task());
30+
julia> tskoid() = objectid(current_task());
3131
3232
julia> asyncmap(x->tskoid(), 1:5)
3333
5-element Array{UInt64,1}:

base/deprecated.jl

+7
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,13 @@ end
15631563
@deprecate findn(x::AbstractMatrix) (I = findall(!iszero, x); (getindex.(I, 1), getindex.(I, 2)))
15641564
@deprecate findn(x::AbstractArray{T, N}) where {T, N} (I = findall(!iszero, x); ntuple(i -> getindex.(I, i), N))
15651565

1566+
@deprecate catch_stacktrace(c_funcs::Bool) stacktrace(catch_backtrace(), c_funcs)
1567+
@deprecate catch_stacktrace() stacktrace(catch_backtrace())
1568+
1569+
@deprecate method_exists hasmethod
1570+
1571+
@deprecate object_id objectid
1572+
15661573
# issue #9053
15671574
if Sys.iswindows()
15681575
function Filesystem.tempname(uunique::UInt32)

base/exports.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ export
692692
isimmutable,
693693
isless,
694694
ifelse,
695-
object_id,
695+
objectid,
696696
sizeof,
697697

698698
# tasks and conditions
@@ -745,7 +745,6 @@ export
745745
StackTrace,
746746
StackFrame,
747747
stacktrace,
748-
catch_stacktrace,
749748

750749
# types
751750
convert,
@@ -789,7 +788,7 @@ export
789788
isconst,
790789
isinteractive,
791790
less,
792-
method_exists,
791+
hasmethod,
793792
methods,
794793
methodswith,
795794
module_name,

base/hashing.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ hash(w::WeakRef, h::UInt) = hash(w.value, h)
2020

2121
## hashing general objects ##
2222

23-
hash(@nospecialize(x), h::UInt) = hash_uint(3h - object_id(x))
23+
hash(@nospecialize(x), h::UInt) = hash_uint(3h - objectid(x))
2424

2525
## core data hashing functions ##
2626

base/irrationals.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ isinteger(::AbstractIrrational) = false
114114
iszero(::AbstractIrrational) = false
115115
isone(::AbstractIrrational) = false
116116

117-
hash(x::Irrational, h::UInt) = 3*object_id(x) - h
117+
hash(x::Irrational, h::UInt) = 3*objectid(x) - h
118118

119119
widen(::Type{T}) where {T<:Irrational} = T
120120

base/multimedia.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ false
4242
```
4343
"""
4444
mimewritable(::MIME{mime}, x) where {mime} =
45-
method_exists(show, Tuple{IO, MIME{mime}, typeof(x)})
45+
hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)})
4646

4747
"""
4848
show(io, mime, x)
@@ -313,7 +313,7 @@ function display(m::MIME, x)
313313
end
314314

315315
displayable(d::D, ::MIME{mime}) where {D<:AbstractDisplay,mime} =
316-
method_exists(display, Tuple{D,MIME{mime},Any})
316+
hasmethod(display, Tuple{D,MIME{mime},Any})
317317

318318
function displayable(m::MIME)
319319
for d in displays

base/namedtuple.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ isequal(a::NamedTuple, b::NamedTuple) = false
101101
_nt_names(::NamedTuple{names}) where {names} = names
102102
_nt_names(::Type{T}) where {names,T<:NamedTuple{names}} = names
103103

104-
hash(x::NamedTuple, h::UInt) = xor(object_id(_nt_names(x)), hash(Tuple(x), h))
104+
hash(x::NamedTuple, h::UInt) = xor(objectid(_nt_names(x)), hash(Tuple(x), h))
105105

106106
isless(a::NamedTuple{n}, b::NamedTuple{n}) where {n} = isless(Tuple(a), Tuple(b))
107107
# TODO: case where one argument's names are a prefix of the other's

base/reflection.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ macro isdefined(s::Symbol)
216216
end
217217

218218
"""
219-
object_id(x)
219+
objectid(x)
220220
221-
Get a hash value for `x` based on object identity. `object_id(x)==object_id(y)` if `x === y`.
221+
Get a hash value for `x` based on object identity. `objectid(x)==objectid(y)` if `x === y`.
222222
"""
223-
object_id(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x)
223+
objectid(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x)
224224

225225
struct DataTypeLayout
226226
nfields::UInt32
@@ -1004,18 +1004,18 @@ function function_module(@nospecialize(f), @nospecialize(types))
10041004
end
10051005

10061006
"""
1007-
method_exists(f, Tuple type, world=typemax(UInt)) -> Bool
1007+
hasmethod(f, Tuple type, world=typemax(UInt)) -> Bool
10081008
10091009
Determine whether the given generic function has a method matching the given
10101010
`Tuple` of argument types with the upper bound of world age given by `world`.
10111011
10121012
# Examples
10131013
```jldoctest
1014-
julia> method_exists(length, Tuple{Array})
1014+
julia> hasmethod(length, Tuple{Array})
10151015
true
10161016
```
10171017
"""
1018-
function method_exists(@nospecialize(f), @nospecialize(t), world=typemax(UInt))
1018+
function hasmethod(@nospecialize(f), @nospecialize(t), world=typemax(UInt))
10191019
t = to_tuple_type(t)
10201020
t = signature_type(f, t)
10211021
return ccall(:jl_method_exists, Cint, (Any, Any, UInt), typeof(f).name.mt, t, world) != 0

base/replutil.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ function showerror(io::IO, ex::MethodError)
386386
# Check for local functions that shadow methods in Base
387387
if f_is_function && isdefined(Base, name)
388388
basef = getfield(Base, name)
389-
if basef !== ex.f && method_exists(basef, arg_types)
389+
if basef !== ex.f && hasmethod(basef, arg_types)
390390
println(io)
391391
print(io, "You may have intended to import Base.", name)
392392
end
393393
end
394-
if (ex.world != typemax(UInt) && method_exists(ex.f, arg_types) &&
395-
!method_exists(ex.f, arg_types, ex.world))
394+
if (ex.world != typemax(UInt) && hasmethod(ex.f, arg_types) &&
395+
!hasmethod(ex.f, arg_types, ex.world))
396396
curworld = ccall(:jl_get_world_counter, UInt, ())
397397
println(io)
398398
print(io, "The applicable method may be too new: running in world age $(ex.world), while current world is $(curworld).")

base/stacktraces.jl

+2-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Base.Serializer: serialize, deserialize
1111
using Base.Printf: @printf
1212
using Base: coalesce
1313

14-
export StackTrace, StackFrame, stacktrace, catch_stacktrace
14+
export StackTrace, StackFrame, stacktrace
1515

1616
"""
1717
StackFrame
@@ -71,7 +71,7 @@ StackFrame(func, file, line) = StackFrame(Symbol(func), Symbol(file), line,
7171
StackTrace
7272
7373
An alias for `Vector{StackFrame}` provided for convenience; returned by calls to
74-
`stacktrace` and `catch_stacktrace`.
74+
`stacktrace`.
7575
"""
7676
const StackTrace = Vector{StackFrame}
7777

@@ -261,14 +261,6 @@ end
261261

262262
stacktrace(c_funcs::Bool=false) = stacktrace(backtrace(), c_funcs)
263263

264-
"""
265-
catch_stacktrace([c_funcs::Bool=false]) -> StackTrace
266-
267-
Returns the stack trace for the most recent error thrown, rather than the current execution
268-
context.
269-
"""
270-
catch_stacktrace(c_funcs::Bool=false) = stacktrace(catch_backtrace(), c_funcs)
271-
272264
"""
273265
remove_frames!(stack::StackTrace, name::Symbol)
274266

doc/src/base/base.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Core.typeassert
111111
Core.typeof
112112
Core.tuple
113113
Base.ntuple
114-
Base.object_id
114+
Base.objectid
115115
Base.hash
116116
Base.finalizer
117117
Base.finalize
@@ -176,7 +176,7 @@ Base.Enums.@enum
176176

177177
```@docs
178178
Core.Function
179-
Base.method_exists
179+
Base.hasmethod
180180
Core.applicable
181181
Core.invoke
182182
Base.invokelatest

doc/src/base/stacktraces.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Base.StackTraces.StackFrame
55
Base.StackTraces.StackTrace
66
Base.StackTraces.stacktrace
7-
Base.StackTraces.catch_stacktrace
87
```
98

109
The following methods and types in `Base.StackTraces` are not exported and need to be called e.g.

doc/src/manual/metaprogramming.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ When defining generated functions, there are four main differences to ordinary f
10731073
3. Instead of calculating something or performing some action, you return a *quoted expression* which,
10741074
when evaluated, does what you want.
10751075
4. Generated functions must not *mutate* or *observe* any non-constant global state (including,
1076-
for example, IO, locks, non-local dictionaries, or using `method_exists`).
1076+
for example, IO, locks, non-local dictionaries, or using `hasmethod`).
10771077
This means they can only read global constants, and cannot have any side effects.
10781078
In other words, they must be completely pure.
10791079
Due to an implementation limitation, this also means that they currently cannot define a closure

doc/src/manual/modules.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ are a trickier case. In the common case where the keys are numbers, strings, sy
299299
`Expr`, or compositions of these types (via arrays, tuples, sets, pairs, etc.) they are safe to
300300
precompile. However, for a few other key types, such as `Function` or `DataType` and generic
301301
user-defined types where you haven't defined a `hash` method, the fallback `hash` method depends
302-
on the memory address of the object (via its `object_id`) and hence may change from run to run.
302+
on the memory address of the object (via its `objectid`) and hence may change from run to run.
303303
If you have one of these key types, or if you aren't sure, to be safe you can initialize this
304304
dictionary from within your `__init__` function. Alternatively, you can use the `IdDict`
305305
dictionary type, which is specially handled by precompilation so that it is safe to initialize
@@ -328,7 +328,7 @@ Other known potential failure scenarios include:
328328
at the end of compilation. All subsequent usages of this incrementally compiled module will start
329329
from that same counter value.
330330

331-
Note that `object_id` (which works by hashing the memory pointer) has similar issues (see notes
331+
Note that `objectid` (which works by hashing the memory pointer) has similar issues (see notes
332332
on `Dict` usage below).
333333

334334
One alternative is to use a macro to capture [`@__MODULE__`](@ref) and store it alone with the current `counter` value,

doc/src/manual/stacktraces.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ frame is missing entirely. This is understandable, given that [`stacktrace`](@re
131131
from the context of the *catch*. While in this example it's fairly easy to find the actual source
132132
of the error, in complex cases tracking down the source of the error becomes nontrivial.
133133

134-
This can be remedied by calling [`catch_stacktrace`](@ref) instead of [`stacktrace`](@ref).
135-
Instead of returning callstack information for the current context, [`catch_stacktrace`](@ref)
134+
This can be remedied by passing the result of [`catch_backtrace`](@ref) to [`stacktrace`](@ref).
135+
Instead of returning callstack information for the current context, [`catch_backtrace`](@ref)
136136
returns stack information for the context of the most recent exception:
137137

138138
```julia-repl
@@ -142,7 +142,7 @@ bad_function (generic function with 1 method)
142142
julia> @noinline example() = try
143143
bad_function()
144144
catch
145-
catch_stacktrace()
145+
stacktrace(catch_backtrace())
146146
end
147147
example (generic function with 1 method)
148148
@@ -167,7 +167,7 @@ julia> @noinline function grandparent()
167167
parent()
168168
catch err
169169
println("ERROR: ", err.msg)
170-
catch_stacktrace()
170+
stacktrace(catch_backtrace())
171171
end
172172
end
173173
grandparent (generic function with 1 method)

examples/staged.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro staged(fdef)
3232
($gengf)() = 0 # should be initially empty GF
3333
function ($fname)($(argspec...))
3434
($argtypes) = typeof(tuple($(argnames...)))
35-
if !method_exists($gengf, $argtypes)
35+
if !hasmethod($gengf, $argtypes)
3636
($genbody) = apply(($expander), ($argtypes))
3737
add_method($gengf, Any[$(qargnames...)],
3838
$argtypes, $genbody)

stdlib/Distributed/src/clusterserialize.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mutable struct ClusterSerializer{I<:IO} <: AbstractSerializer
1414

1515
pid::Int # Worker we are connected to.
1616
tn_obj_sent::Set{UInt64} # TypeName objects sent
17-
glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (object_id, hash_value)
17+
glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (objectid, hash_value)
1818
glbs_in_tnobj::Dict{UInt64, Vector{Symbol}} # Track globals referenced in
1919
# anonymous functions.
2020
anonfunc_id::UInt64
@@ -116,7 +116,7 @@ function serialize(s::ClusterSerializer, g::GlobalRef)
116116
end
117117

118118
# Send/resend a global object if
119-
# a) has not been sent previously, i.e., we are seeing this object_id for the first time, or,
119+
# a) has not been sent previously, i.e., we are seeing this objectid for the first time, or,
120120
# b) hash value has changed or
121121
# c) is a bits type
122122
function syms_2b_sent(s::ClusterSerializer, identifier)
@@ -128,7 +128,7 @@ function syms_2b_sent(s::ClusterSerializer, identifier)
128128
if isbits(v)
129129
push!(lst, sym)
130130
else
131-
oid = object_id(v)
131+
oid = objectid(v)
132132
if haskey(s.glbs_sent, oid)
133133
# We have sent this object before, see if it has changed.
134134
s.glbs_sent[oid] != hash(sym, hash(v)) && push!(lst, sym)
@@ -143,7 +143,7 @@ end
143143
function serialize_global_from_main(s::ClusterSerializer, sym)
144144
v = getfield(Main, sym)
145145

146-
oid = object_id(v)
146+
oid = objectid(v)
147147
record_v = true
148148
if isbits(v)
149149
record_v = false
@@ -179,7 +179,7 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
179179
end
180180

181181
function delete_global_tracker(s::ClusterSerializer, v)
182-
oid = object_id(v)
182+
oid = objectid(v)
183183
if haskey(s.glbs_sent, oid)
184184
delete!(s.glbs_sent, oid)
185185
end

stdlib/Distributed/test/distributed_exec.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,8 @@ v6 = FooModEverywhere
11611161
Base.Serializer.serialize_type(s, TestSerCnt)
11621162
serialize(s, t.v)
11631163
global testsercnt_d
1164-
cnt = get!(testsercnt_d, object_id(t), 0)
1165-
testsercnt_d[object_id(t)] = cnt+1
1164+
cnt = get!(testsercnt_d, objectid(t), 0)
1165+
testsercnt_d[objectid(t)] = cnt+1
11661166
end
11671167

11681168
Base.deserialize(s::AbstractSerializer, ::Type{TestSerCnt}) = TestSerCnt(deserialize(s))
@@ -1174,22 +1174,22 @@ for i in 1:5
11741174
remotecall_fetch(()->tsc, id_other)
11751175
end
11761176
# should have been serialized only once
1177-
@test testsercnt_d[object_id(tsc)] == 1
1177+
@test testsercnt_d[objectid(tsc)] == 1
11781178

11791179
# hash values are changed
11801180
n=5
1181-
testsercnt_d[object_id(tsc)] = 0
1181+
testsercnt_d[objectid(tsc)] = 0
11821182
for i in 1:n
11831183
tsc.v[i] = i
11841184
remotecall_fetch(()->tsc, id_other)
11851185
end
11861186
# should have been serialized as many times as the loop
1187-
@test testsercnt_d[object_id(tsc)] == n
1187+
@test testsercnt_d[objectid(tsc)] == n
11881188

11891189
# Multiple references in a closure should be serialized only once.
11901190
global mrefs = TestSerCnt(fill(1.,10))
11911191
@test remotecall_fetch(()->(mrefs.v, 2*mrefs.v, 3*mrefs.v), id_other) == (fill(1.,10), fill(2.,10), fill(3.,10))
1192-
@test testsercnt_d[object_id(mrefs)] == 1
1192+
@test testsercnt_d[objectid(mrefs)] == 1
11931193

11941194

11951195
# nested anon functions
@@ -1239,9 +1239,9 @@ global ids_func = ()->ids_cleanup
12391239
clust_ser = (Distributed.worker_from_id(id_other)).w_serializer
12401240
@test remotecall_fetch(ids_func, id_other) == ids_cleanup
12411241

1242-
@test haskey(clust_ser.glbs_sent, object_id(ids_cleanup))
1242+
@test haskey(clust_ser.glbs_sent, objectid(ids_cleanup))
12431243
finalize(ids_cleanup)
1244-
@test !haskey(clust_ser.glbs_sent, object_id(ids_cleanup))
1244+
@test !haskey(clust_ser.glbs_sent, objectid(ids_cleanup))
12451245

12461246
# TODO Add test for cleanup from `clust_ser.glbs_in_tnobj`
12471247

stdlib/SharedArrays/test/runtests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ finalize(d)
284284
let
285285
aorig = a1 = SharedArray{Float64}((3, 3))
286286
a1 = remotecall_fetch(fill!, id_other, a1, 1.0)
287-
@test object_id(aorig) == object_id(a1)
287+
@test objectid(aorig) == objectid(a1)
288288
id = a1.id
289289
aorig = nothing
290290
a1 = remotecall_fetch(fill!, id_other, a1, 1.0)

0 commit comments

Comments
 (0)