From 04f5d9197a03c05414738aefe5807a2029eb92dd Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Tue, 28 Nov 2017 13:35:11 -0800 Subject: [PATCH] Deprecate Array(shape...)-like constructors to Array(uninitialized, shape...) equivalents. --- NEWS.md | 8 ++++++++ base/boot.jl | 14 -------------- base/deprecated.jl | 21 +++++++++++++++++++++ base/sysimg.jl | 13 ------------- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/NEWS.md b/NEWS.md index a9d2533299cf27..a69577e6bc01e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -421,6 +421,14 @@ Deprecated or removed Instead, reshape the array or add trailing indices so the dimensionality and number of indices match ([#14770], [#23628]). + * Uninitialized `Array` constructors of the form + `Array[{T,N}](shape...)` have been deprecated in favor of equivalents + accepting `uninitialized` (an alias for `Uninitialized()`) as their first argument, + as in `Array[{T,N}](uninitialized, shape...)`. For example, + `Vector(3)` is now `Vector(uninitialized, 3)`, `Matrix{Int}((2, 4))` is now, + `Matrix{Int}(uninitialized, (2, 4))`, and `Array{Float32,3}(11, 13, 17)` is now + `Array{Float32,3}(uninitialized, 11, 13, 17)` ([#24781]). + * `fill!(A::Diagonal, x)` and `fill!(A::AbstractTriangular, x)` have been deprecated in favor of `Base.LinAlg.fillslots!(A, x)` ([#24413]). diff --git a/base/boot.jl b/base/boot.jl index b357c5ec45ad2c..40baf0f84b3141 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -373,20 +373,6 @@ Array{T}(::Uninitialized, d::NTuple{N,Int}) where {T,N} = Array{T,N}(uninitializ # empty vector constructor Array{T,1}() where {T} = Array{T,1}(uninitialized, 0) -## preexisting Array constructors, i.e. without uninitialized, to deprecate -# type and dimensionality specified, accepting dims as series of Ints -Array{T,1}(m::Int) where {T} = Array{T,1}(uninitialized, m) -Array{T,2}(m::Int, n::Int) where {T} = Array{T,2}(uninitialized, m, n) -Array{T,3}(m::Int, n::Int, o::Int) where {T} = Array{T,3}(uninitialized, m, n, o) -Array{T,N}(d::Vararg{Int,N}) where {T,N} = Array{T,N}(uninitialized, d) -# type and dimensionality specified, accepting dims as tuples of Ints -Array{T,N}(d::NTuple{N,Int}) where {T,N} = Array{T,N}(uninitialized, d) -# type but not dimensionality specified -Array{T}(m::Int) where {T} = Array{T}(uninitialized, m) -Array{T}(m::Int, n::Int) where {T} = Array{T}(uninitialized, m, n) -Array{T}(m::Int, n::Int, o::Int) where {T} = Array{T}(uninitialized, m, n, o) -Array{T}(d::NTuple{N,Int}) where {T,N} = Array{T}(uninitialized, d) - # primitive Symbol constructors function Symbol(s::String) diff --git a/base/deprecated.jl b/base/deprecated.jl index f037e84656c4e1..015e5dc30e5561 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -2043,6 +2043,27 @@ end # issue #24006 @deprecate linearindices(s::AbstractString) eachindex(s) +# deprecate Array(shape...)-like constructors to Array(uninitialized, shape...) equivalents +# --> former primitive constructors +@deprecate Array{T,1}(m::Int) where {T} Array{T,1}(uninitialized, m) +@deprecate Array{T,2}(m::Int, n::Int) where {T} Array{T,2}(uninitialized, m, n) +@deprecate Array{T,3}(m::Int, n::Int, o::Int) where {T} Array{T,3}(uninitialized, m, n, o) +@deprecate Array{T,N}(d::Vararg{Int,N}) where {T,N} Array{T,N}(uninitialized, d) +@deprecate Array{T,N}(d::NTuple{N,Int}) where {T,N} Array{T,N}(uninitialized, d) +@deprecate Array{T}(m::Int) where {T} Array{T}(uninitialized, m) +@deprecate Array{T}(m::Int, n::Int) where {T} Array{T}(uninitialized, m, n) +@deprecate Array{T}(m::Int, n::Int, o::Int) where {T} Array{T}(uninitialized, m, n, o) +@deprecate Array{T}(d::NTuple{N,Int}) where {T,N} Array{T}(uninitialized, d) +# --> former convenience constructors +@deprecate Vector{T}(m::Integer) where {T} Vector{T}(uninitialized, m) +@deprecate Matrix{T}(m::Integer, n::Integer) where {T} Matrix{T}(uninitialized, m, n) +@deprecate Array{T}(m::Integer) where {T} Array{T}(uninitialized, m) +@deprecate Array{T}(m::Integer, n::Integer) where {T} Array{T}(uninitialized, m, n) +@deprecate Array{T}(m::Integer, n::Integer, o::Integer) where {T} Array{T}(uninitialized, m, n, o) +@deprecate Array{T}(d::Integer...) where {T} Array{T}(uninitialized, d) +@deprecate Vector(m::Integer) Vector(uninitialized, m) +@deprecate Matrix(m::Integer, n::Integer) Matrix(uninitialized, m, n) + # deprecate IntSet to BitSet @deprecate_binding IntSet BitSet diff --git a/base/sysimg.jl b/base/sysimg.jl index e0000f60b2e5fc..dc306230757dee 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -146,19 +146,6 @@ Matrix(::Uninitialized, m::Integer, n::Integer) = Matrix{Any}(uninitialized, Int # empty vector constructor Vector() = Vector{Any}(uninitialized, 0) -## preexisting dims-type-converting Array constructors for convenience, i.e. without uninitialized, to deprecate -# type and dimensionality specified, accepting dims as series of Integers -Vector{T}(m::Integer) where {T} = Vector{T}(uninitialized, Int(m)) -Matrix{T}(m::Integer, n::Integer) where {T} = Matrix{T}(uninitialized, Int(m), Int(n)) -# type but not dimensionality specified, accepting dims as series of Integers -Array{T}(m::Integer) where {T} = Vector{T}(uninitialized, Int(m)) -Array{T}(m::Integer, n::Integer) where {T} = Array{T,2}(uninitialized, Int(m), Int(n)) -Array{T}(m::Integer, n::Integer, o::Integer) where {T} = Array{T,3}(uninitialized, Int(m), Int(n), Int(o)) -Array{T}(d::Integer...) where {T} = Array{T}(uninitialized, convert(Tuple{Vararg{Int}}, d)) -# dimensionality but not type specified, accepting dims as series of Integers -Vector(m::Integer) = Vector{Any}(uninitialized, Int(m)) -Matrix(m::Integer, n::Integer) = Matrix{Any}(uninitialized, Int(m), Int(n)) - include("associative.jl")