Ndim (>=3) Array constructors without argument does not work

question

#1

Hi, I am wondering why the default constructors without an argument for Array, e.g., Array{Float64,1}() and Array{Float64,2}() work without any problems while Array{Float64,3}() gives the following error?

Closest candidates are:
  Array{Float64,3}{T,N}(!Matched::Tuple{Vararg{Int64,N}}) at boot.jl:310
  Array{Float64,3}{T}(!Matched::Int64, !Matched::Int64, !Matched::Int64) at boot.jl:316
  Array{Float64,3}{T}(!Matched::Any) at sysimg.jl:53

On the other hand, zeros(0); zeros(0,0); zeros(0,0,0) all work.
Thanks!
BVPs


#2

On 0.6 (master) we decided that a zero size Vector/Matrix isn’t special enough so the sizes are required and the Vector{T}() constructors are deprecated.


#3

@yuyichao: thanks! Then in v0.6, should ```zeros(0); zeros(0,0); zeros(0,0,0)```` etc., still work?


#4

Yes, they should, just like the Array{...}(x, y, z...)s. The removal (deprecation) of Vector{T}() and Matrix{T}() just make this more consistent (since you can’t do zeros() and get a 1 or 2d array anyway…)

julia> zeros(0)
0-element Array{Float64,1}

julia> zeros(0, 0)
0×0 Array{Float64,2}

julia> zeros(0, 0, 0)
0×0×0 Array{Float64,3}

julia> Array{Float64,1}(0)
0-element Array{Float64,1}

julia> Array{Float64,2}(0, 0)
0×0 Array{Float64,2}

julia> Array{Float64,3}(0, 0, 0)
0×0×0 Array{Float64,3}

julia> Array{Float64}(0)
0-element Array{Float64,1}

julia> Array{Float64}(0, 0)
0×0 Array{Float64,2}

julia> Array{Float64}(0, 0, 0)
0×0×0 Array{Float64,3}

#5

Thank you very much, @yuyichao! Then, I’ll start revising my codes accordingly to prepare for v0.6.