Skip to content

Commit ef7046d

Browse files
authored
Merge branch 'master' into jb/rmsyntaxdeps
2 parents 0352af0 + e480969 commit ef7046d

39 files changed

+824
-411
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ This section lists changes that do not have deprecation warnings.
169169
* `A=>B` expressions are now parsed as calls instead of using `=>` as the
170170
expression head ([#20327]).
171171

172+
* The `count` function no longer sums non-boolean values ([#20404])
173+
172174
Library improvements
173175
--------------------
174176

@@ -239,6 +241,8 @@ Library improvements
239241

240242
* Additional methods for `ones` and `zeros` functions to support the same signature as the `similar` function ([#19635]).
241243

244+
* `count` now has a `count(itr)` method equivalent to `count(identity, itr)` ([#20403]).
245+
242246
* Methods for `map` and `filter` with `Nullable` arguments have been
243247
implemented; the semantics are as if the `Nullable` were a container with
244248
zero or one elements ([#16961]).

base/LineEdit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ end
13061306
"""
13071307
`Base.LineEdit.tabwidth` controls the presumed tab width of code pasted into the REPL.
13081308
1309-
You can modify it by doing `eval(Base.LineEdit, :(tabwidth = 4))`, for example.
1309+
You can modify it by doing `@eval Base.LineEdit tabwidth = 4`, for example.
13101310
13111311
Must satisfy `0 < tabwidth <= 16`.
13121312
"""

base/Terminals.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ cmove_up(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)A")
111111
cmove_down(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)B")
112112
cmove_right(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)C")
113113
cmove_left(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)D")
114-
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 0))
115-
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 0))
114+
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 1))
115+
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1))
116116
cmove_col(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)G")
117117

118118
if is_windows()

base/array.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ typealias DenseVecOrMat{T} Union{DenseVector{T}, DenseMatrix{T}}
2626
import Core: arraysize, arrayset, arrayref
2727

2828
"""
29+
Array{T}(dims)
2930
Array{T,N}(dims)
3031
31-
Construct an uninitialized `N`-dimensional dense array with element type `T`. `dims` may
32-
be a tuple or a series of integer arguments corresponding to the length in each dimension.
33-
If the rank `N` is omitted, i.e. `Array{T}(dims)`, the rank is determined based on `dims`.
32+
Construct an uninitialized `N`-dimensional dense array with element type `T`,
33+
where `N` is determined from the length or number of `dims`. `dims` may
34+
be a tuple or a series of integer arguments corresponding to the lengths in each dimension.
35+
If the rank `N` is supplied explicitly as in `Array{T,N}(dims)`, then it must
36+
match the length or number of `dims`.
3437
"""
3538
Array
3639

base/bitarray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,7 @@ function countnz(B::BitArray)
15751575
end
15761576
return n
15771577
end
1578+
count(B::BitArray) = countnz(B)
15781579

15791580
# returns the index of the next non-zero element, or 0 if all zeros
15801581
function findnext(B::BitArray, start::Integer)

base/client.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function __atreplinit(repl)
356356
end
357357
end
358358
end
359-
_atreplinit(repl) = eval(Main, :($__atreplinit($repl)))
359+
_atreplinit(repl) = @eval Main $__atreplinit($repl)
360360

361361
function _start()
362362
empty!(ARGS)

base/clusterserialize.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
136136
sym_isconst = deserialize(s)
137137
v = deserialize(s)
138138
if sym_isconst
139-
eval(Main, :(const $sym = $v))
139+
@eval Main const $sym = $v
140140
else
141-
eval(Main, :($sym = $v))
141+
@eval Main $sym = $v
142142
end
143143
end
144144

base/deprecated.jl

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ for f in ( :acos_fast, :acosh_fast, :angle_fast, :asin_fast, :asinh_fast,
249249
:cosh_fast, :exp10_fast, :exp2_fast, :exp_fast, :expm1_fast,
250250
:lgamma_fast, :log10_fast, :log1p_fast, :log2_fast, :log_fast,
251251
:sin_fast, :sinh_fast, :sqrt_fast, :tan_fast, :tanh_fast )
252-
eval(FastMath, :(Base.@dep_vectorize_1arg Number $f))
252+
@eval FastMath Base.@dep_vectorize_1arg Number $f
253253
end
254254
for f in (
255255
:invdigamma, # base/special/gamma.jl
@@ -265,7 +265,7 @@ end
265265
@dep_vectorize_1arg Complex float
266266
# base/dates/*.jl
267267
for f in (:unix2datetime, :rata2datetime, :julian2datetime) # base/dates/conversions.jl
268-
eval(Dates, :(Base.@dep_vectorize_1arg Real $f))
268+
@eval Dates Base.@dep_vectorize_1arg Real $f
269269
end
270270
for f in (
271271
# base/dates/accessors.jl
@@ -279,15 +279,15 @@ for f in (
279279
:daysofweekinmonth, :monthname, :monthabbr, :daysinmonth,
280280
:isleapyear, :dayofyear, :daysinyear, :quarterofyear, :dayofquarter,
281281
)
282-
eval(Dates, :(Base.@dep_vectorize_1arg Dates.TimeType $f))
282+
@eval Dates Base.@dep_vectorize_1arg Dates.TimeType $f
283283
end
284284
for f in (
285285
:hour, :minute, :second, :millisecond, # base/dates/accessors.jl
286286
:Date, :datetime2unix, :datetime2rata, :datetime2julian, # base/dates/conversions.jl
287287
)
288-
eval(Dates, :(Base.@dep_vectorize_1arg Dates.DateTime $f))
288+
@eval Dates Base.@dep_vectorize_1arg Dates.DateTime $f
289289
end
290-
eval(Dates, :(Base.@dep_vectorize_1arg Dates.Date Datetime)) # base/dates/conversions.jl
290+
@eval Dates Base.@dep_vectorize_1arg Dates.Date Datetime # base/dates/conversions.jl
291291

292292
# Deprecate @vectorize_2arg-vectorized functions from...
293293
for f in (
@@ -304,7 +304,7 @@ for f in (
304304
end
305305
# base/fastmath.jl
306306
for f in (:pow_fast, :atan2_fast, :hypot_fast, :max_fast, :min_fast, :minmax_fast)
307-
eval(FastMath, :(Base.@dep_vectorize_2arg Number $f))
307+
@eval FastMath Base.@dep_vectorize_2arg Number $f
308308
end
309309
for f in (
310310
:max, :min, # base/math.jl
@@ -356,14 +356,14 @@ end
356356
@deprecate abs(x::AbstractSparseVector) abs.(x)
357357

358358
# Deprecate @textmime into the Multimedia module, #18441
359-
eval(Multimedia, :(macro textmime(mime)
359+
@eval Multimedia macro textmime(mime)
360360
Base.depwarn(string("`@textmime \"mime\"` is deprecated; use ",
361361
"`Base.Multimedia.istextmime(::MIME\"mime\") = true` instead"
362362
), :textmime)
363363
quote
364364
Base.Multimedia.istextmime(::MIME{$(Meta.quot(Symbol(mime)))}) = true
365365
end
366-
end))
366+
end
367367

368368
@deprecate ipermutedims(A::AbstractArray,p) permutedims(A, invperm(p))
369369

@@ -440,7 +440,7 @@ function reduced_dims0(a::AbstractArray, region)
440440
end
441441

442442
# #18218
443-
eval(Base.LinAlg, quote
443+
@eval Base.LinAlg begin
444444
function arithtype(T)
445445
Base.depwarn(string("arithtype is now deprecated. If you were using it inside a ",
446446
"promote_op call, use promote_op(LinAlg.matprod, Ts...) instead. Otherwise, ",
@@ -455,7 +455,7 @@ eval(Base.LinAlg, quote
455455
:arithtype)
456456
Int
457457
end
458-
end)
458+
end
459459

460460
# #19246
461461
@deprecate den denominator
@@ -468,7 +468,7 @@ Filesystem.stop_watching(stream::Filesystem._FDWatcher) = depwarn("stop_watching
468468
@deprecate takebuf_string(b) String(take!(b))
469469

470470
# #19288
471-
eval(Base.Dates, quote
471+
@eval Base.Dates begin
472472
function recur{T<:TimeType}(fun::Function, dr::StepRange{T}; negate::Bool=false, limit::Int=10000)
473473
Base.depwarn("Dates.recur is deprecated, use filter instead.",:recur)
474474
if negate
@@ -478,7 +478,7 @@ eval(Base.Dates, quote
478478
end
479479
end
480480
recur{T<:TimeType}(fun::Function, start::T, stop::T; step::Period=Day(1), negate::Bool=false, limit::Int=10000) = recur(fun, start:step:stop; negate=negate)
481-
end)
481+
end
482482

483483
# Index conversions revamp; #19730
484484
function getindex(A::LogicalIndex, i::Int)
@@ -655,13 +655,15 @@ function _depwarn_bczpres!(f, args...)
655655
depwarn(_depstring_bczpres(), :broadcast_zpreserving!)
656656
return _broadcast_zpreserving!(f, args...)
657657
end
658-
eval(SparseArrays, :(broadcast_zpreserving(f, args...) = Base._depwarn_bczpres(f, args...)))
659-
eval(SparseArrays, :(broadcast_zpreserving(f, A::SparseMatrixCSC, B::SparseMatrixCSC) = Base._depwarn_bczpres(f, A, B)))
660-
eval(SparseArrays, :(broadcast_zpreserving(f, A::SparseMatrixCSC, B::Union{Array,BitArray,Number}) = Base._depwarn_bczpres(f, A, B)))
661-
eval(SparseArrays, :(broadcast_zpreserving(f, A::Union{Array,BitArray,Number}, B::SparseMatrixCSC) = Base._depwarn_bczpres(f, A, B)))
662-
eval(SparseArrays, :(broadcast_zpreserving!(f, args...) = Base._depwarn_bczpres!(f, args...)))
663-
eval(SparseArrays, :(broadcast_zpreserving!(f, C::SparseMatrixCSC, A::SparseMatrixCSC, B::Union{Array,BitArray,Number}) = Base._depwarn_bczpres!(f, C, A, B)))
664-
eval(SparseArrays, :(broadcast_zpreserving!(f, C::SparseMatrixCSC, A::Union{Array,BitArray,Number}, B::SparseMatrixCSC) = Base._depwarn_bczpres!(f, C, A, B)))
658+
@eval SparseArrays begin
659+
broadcast_zpreserving(f, args...) = Base._depwarn_bczpres(f, args...)
660+
broadcast_zpreserving(f, A::SparseMatrixCSC, B::SparseMatrixCSC) = Base._depwarn_bczpres(f, A, B)
661+
broadcast_zpreserving(f, A::SparseMatrixCSC, B::Union{Array,BitArray,Number}) = Base._depwarn_bczpres(f, A, B)
662+
broadcast_zpreserving(f, A::Union{Array,BitArray,Number}, B::SparseMatrixCSC) = Base._depwarn_bczpres(f, A, B)
663+
broadcast_zpreserving!(f, args...) = Base._depwarn_bczpres!(f, args...)
664+
broadcast_zpreserving!(f, C::SparseMatrixCSC, A::SparseMatrixCSC, B::Union{Array,BitArray,Number}) = Base._depwarn_bczpres!(f, C, A, B)
665+
broadcast_zpreserving!(f, C::SparseMatrixCSC, A::Union{Array,BitArray,Number}, B::SparseMatrixCSC) = Base._depwarn_bczpres!(f, C, A, B)
666+
end
665667

666668
# #19719
667669
@deprecate getindex(t::Tuple, r::AbstractArray) getindex(t, vec(r))
@@ -1030,7 +1032,7 @@ iteratoreltype(::Type{Task}) = EltypeUnknown()
10301032

10311033
isempty(::Task) = error("isempty not defined for Tasks")
10321034

1033-
eval(Base.Test, quote
1035+
@eval Base.Test begin
10341036
approx_full(x::AbstractArray) = x
10351037
approx_full(x::Number) = x
10361038
approx_full(x) = full(x)
@@ -1095,7 +1097,7 @@ eval(Base.Test, quote
10951097
:(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b))))
10961098
end
10971099
export @test_approx_eq
1098-
end)
1100+
end
10991101

11001102
# Deprecate partial linear indexing
11011103
function partial_linear_indexing_warning_lookup(nidxs_remaining)
@@ -1138,23 +1140,23 @@ function partial_linear_indexing_warning(n)
11381140
end
11391141

11401142
# Deprecate Array(T, dims...) in favor of proper type constructors
1141-
@deprecate Array{T,N}(::Type{T}, d::NTuple{N,Int}) Array{T,N}(d)
1142-
@deprecate Array{T}(::Type{T}, d::Int...) Array{T,length(d)}(d...)
1143-
@deprecate Array{T}(::Type{T}, m::Int) Array{T,1}(m)
1144-
@deprecate Array{T}(::Type{T}, m::Int,n::Int) Array{T,2}(m,n)
1145-
@deprecate Array{T}(::Type{T}, m::Int,n::Int,o::Int) Array{T,3}(m,n,o)
1146-
@deprecate Array{T}(::Type{T}, d::Integer...) Array{T,length(d)}(convert(Tuple{Vararg{Int}}, d))
1147-
@deprecate Array{T}(::Type{T}, m::Integer) Array{T,1}(Int(m))
1148-
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer) Array{T,2}(Int(m),Int(n))
1149-
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) Array{T,3}(Int(m),Int(n),Int(o))
1143+
@deprecate Array{T,N}(::Type{T}, d::NTuple{N,Int}) Array{T}(d)
1144+
@deprecate Array{T}(::Type{T}, d::Int...) Array{T}(d...)
1145+
@deprecate Array{T}(::Type{T}, m::Int) Array{T}(m)
1146+
@deprecate Array{T}(::Type{T}, m::Int,n::Int) Array{T}(m,n)
1147+
@deprecate Array{T}(::Type{T}, m::Int,n::Int,o::Int) Array{T}(m,n,o)
1148+
@deprecate Array{T}(::Type{T}, d::Integer...) Array{T}(convert(Tuple{Vararg{Int}}, d))
1149+
@deprecate Array{T}(::Type{T}, m::Integer) Array{T}(Int(m))
1150+
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer) Array{T}(Int(m),Int(n))
1151+
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) Array{T}(Int(m),Int(n),Int(o))
11501152

11511153
# Likewise for SharedArrays
1152-
@deprecate SharedArray{T,N}(::Type{T}, dims::Dims{N}; kwargs...) SharedArray{T,N}(dims; kwargs...)
1153-
@deprecate SharedArray{T}(::Type{T}, dims::Int...; kwargs...) SharedArray{T,length(dims)}(dims...; kwargs...)
1154+
@deprecate SharedArray{T,N}(::Type{T}, dims::Dims{N}; kwargs...) SharedArray{T}(dims; kwargs...)
1155+
@deprecate SharedArray{T}(::Type{T}, dims::Int...; kwargs...) SharedArray{T}(dims...; kwargs...)
11541156
@deprecate(SharedArray{T,N}(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, offset; kwargs...),
1155-
SharedArray{T,N}(filename, dims, offset; kwargs...))
1157+
SharedArray{T}(filename, dims, offset; kwargs...))
11561158
@deprecate(SharedArray{T}(filename::AbstractString, ::Type{T}, dims::NTuple, offset; kwargs...),
1157-
SharedArray{T,length(dims)}(filename, dims, offset; kwargs...))
1159+
SharedArray{T}(filename, dims, offset; kwargs...))
11581160

11591161
@noinline function is_intrinsic_expr(x::ANY)
11601162
Base.depwarn("is_intrinsic_expr is deprecated. There are no intrinsic functions anymore.", :is_intrinsic_expr)
@@ -1177,7 +1179,7 @@ function colon{T<:Dates.Period}(start::T, stop::T)
11771179
end
11781180

11791181
# LibGit2 refactor (#19839)
1180-
eval(Base.LibGit2, quote
1182+
@eval Base.LibGit2 begin
11811183
Base.@deprecate_binding Oid GitHash
11821184
Base.@deprecate_binding GitAnyObject GitUnknownObject
11831185

@@ -1187,23 +1189,21 @@ eval(Base.LibGit2, quote
11871189
@deprecate revparse(repo::GitRepo, objname::AbstractString) GitObject(repo, objname) false
11881190
@deprecate object(repo::GitRepo, te::GitTreeEntry) GitObject(repo, te) false
11891191
@deprecate commit(ann::GitAnnotated) GitHash(ann) false
1190-
end)
1192+
end
11911193

11921194
# when this deprecation is deleted, remove all calls to it, and all
11931195
# negate=nothing keyword arguments, from base/dates/adjusters.jl
1194-
eval(Dates, quote
1195-
function deprecate_negate(f, func, sig, negate)
1196-
if negate === nothing
1197-
return func
1198-
else
1199-
msg = "$f($sig; negate=$negate) is deprecated, use $f("
1200-
negate && (msg *= "!")
1201-
msg *= "$sig) instead."
1202-
Base.depwarn(msg, f)
1203-
return negate ? !func : func
1204-
end
1196+
@eval Dates function deprecate_negate(f, func, sig, negate)
1197+
if negate === nothing
1198+
return func
1199+
else
1200+
msg = "$f($sig; negate=$negate) is deprecated, use $f("
1201+
negate && (msg *= "!")
1202+
msg *= "$sig) instead."
1203+
Base.depwarn(msg, f)
1204+
return negate ? !func : func
12051205
end
1206-
end)
1206+
end
12071207

12081208
# FloatRange replaced by StepRangeLen
12091209

base/dict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ end
662662
start(t::ImmutableDict) = t
663663
next{K,V}(::ImmutableDict{K,V}, t) = (Pair{K,V}(t.key, t.value), t.parent)
664664
done(::ImmutableDict, t) = !isdefined(t, :parent)
665-
length(t::ImmutableDict) = count(x->1, t)
665+
length(t::ImmutableDict) = count(x->true, t)
666666
isempty(t::ImmutableDict) = done(t, start(t))
667667
function similar(t::ImmutableDict)
668668
while isdefined(t, :parent)

base/expr.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,16 @@ evaluates expressions in that module.
109109
Core.eval
110110

111111
"""
112-
@eval
112+
@eval [mod,] ex
113113
114-
Evaluate an expression and return the value.
114+
Evaluate an expression with values interpolated into it using `eval`.
115+
If two arguments are provided, the first is the module to evaluate in.
115116
"""
116-
macro eval(x)
117-
:($(esc(:eval))($(Expr(:quote,x))))
117+
macro eval(ex)
118+
:(eval($(current_module()), $(Expr(:quote,ex))))
119+
end
120+
macro eval(mod, ex)
121+
:(eval($(esc(mod)), $(Expr(:quote,ex))))
118122
end
119123

120124
"""

base/multi.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,4 +2371,4 @@ clear!(sym::Symbol, pids=workers(); mod=Main) = clear!([sym], pids; mod=mod)
23712371
clear!(syms, pid::Int; mod=Main) = clear!(syms, [pid]; mod=mod)
23722372

23732373
clear_impl!(syms, mod::Module) = foreach(x->clear_impl!(x,mod), syms)
2374-
clear_impl!(sym::Symbol, mod::Module) = isdefined(mod, sym) && eval(mod, :(global $sym = nothing))
2374+
clear_impl!(sym::Symbol, mod::Module) = isdefined(mod, sym) && @eval(mod, global $sym = nothing)

0 commit comments

Comments
 (0)