I can create an empty one-dimensional array with a zero-argument constructor:
julia> Vector{Float64}()
Float64[]
But I can’t create an empty multi-dimensional array with a zero-argument constructor:
julia> Array{Float64,2}()
ERROR: MethodError: no method matching Matrix{Float64}()
...
Is there a reason why the zero-argument constructor is not implemented for multi-dimensional arrays? We can certainly create empty multi-dimensional arrays by
Emptiness is determined by one of the dimensions being zero, but the other dimensions can have any size at all. For n = 1 this dictates that the one dimension have size zero, but for larger n the other dimensions are undetermined.
I’m not sure I understood yours either to be honest:
I took this to mean that one possible zero-dimensional array would be the one where there is no value at all, the absence of an object/value, and that you considered that case as an alternative to 0x0 as the canonical case for Array{Float64, 2}(). And then I responded to that by saying that would not preserve the type of the (zero-argument) constructor.
My point was just that if the idea of the zero-argument constructor is to create an empty array, then Array{T, 0} would be a corner case since they don’t have any empty instances.
I think the issue this highlights is that if you’re going to have a convention for a specific empty array being “the standard one” then it’s a bit of an odd smell that in one of the cases (zero dimensions) there is no such array. It’s one of those cases of “if you do this it works… oh but not in this one case, then it doesn’t.” If something can’t really be a consistent convention maybe it shouldn’t be a convention in the first place.
Interestingly, for a given value, there is a unique single-element array of every dimensionality containing just that value because there’s only one way for the product of n dimensions to be 1.