If this was a bug I’m sure it would have been squashed already, so I’m not so worried that this is incorrect behavior per se, but I’m still curious: what’s the motivation for the following behavior?
I would have expected a 0dimensional array to contain no elements in any dimension, but this one seemingly has one (garbage) element anyway. I would have found the following more intuitive:
// T 
0 dimensional arrays are scalars, hence have one element.
On Tue, Nov 24, 2015 at 2:20 AM, Tomas Lycken <[hidden email]> wrote:

Le mardi 24 novembre 2015 à 03:02 0500, Keno Fischer a écrit :
> 0 dimensional arrays are scalars, hence have one element. Yet this difference is a bit disturbing: julia> Array{Int}() 0dimensional Array{Int64,0}: 139800461198672 julia> Vector{Int}() 0element Array{Int64,1} Probably impossible to get rid of, though. Another small inconsistency, which could easily be fixed: julia> Array{Int,1}() 0element Array{Int64,1} julia> Array{Int,0}() ERROR: MethodError: `convert` has no method matching convert(::Type{Array{Int64,0}}) Regards > On Tue, Nov 24, 2015 at 2:20 AM, Tomas Lycken <[hidden email] > > wrote: > > If this was a bug I’m sure it would have been squashed already, so > > I’m not so worried that this is incorrect behavior per se, but I’m > > still curious: what’s the motivation for the following behavior? > > > > julia> a = Array{Int}() > > 0dimensional Array{Int64,0}: > > 2191825968 > > > > julia> length(a) > > 1 > > > > julia> a[1] > > 2191825968 > > I would have expected a 0dimensional array to contain no elements > > in any dimension, but this one seemingly has one (garbage) element > > anyway. > > > > I would have found the following more intuitive: > > > > julia> a = Array{Int}() > > 0dimensional Array{Int64,0} > > > > julia> length(a) > > 0 > > // T > > > > 
It's also only a "garbage element" because you haven't set a value:
julia> a = Array(Int) 0dimensional Array{Int64,0}: 3 julia> a[] = 22 22 julia> a 0dimensional Array{Int64,0}: 22 On Tuesday, November 24, 2015 09:52:18 AM Milan BouchetValat wrote: > Yet this difference is a bit disturbing: > > julia> Array{Int}() > 0dimensional Array{Int64,0}: > 139800461198672 > > julia> Vector{Int}() > 0element Array{Int64,1} > > Probably impossible to get rid of, though. We could delete the fallback (see array.jl) call{T}(::Type{Vector{T}}) = Array{T}(0) and force people to specify the size. Tim 
In reply to this post by Keno Fischer
It does seem confusing that Array{Int}() implies zero dimensions (did the user forget the size parameter or did they intend a zero length dims tuple?). I think it would be more consistent to require either Array{Int,0}() or Array{Int}( () ), and the first form throws an error.
On Tuesday, November 24, 2015 at 3:02:35 AM UTC5, Keno Fischer wrote:

While I understand that zerodimensional arrays are a bit confusing, arbitrarily disallowing the zeroargument case of the Array{T}(dims::Integer...) form is definitely not more consistent. On the contrary, it's the opposite of consistency – it's a special case which would need to be handled everywhere anyone writes uses this form to generically constructs nd arrays. On Tuesday, November 24, 2015, Josh Langsfeld <[hidden email]> wrote:

Yeah, it's definitely consistent from the implementation perspective. But from the user's perspective, it's weird because the cases of 'failed to specify a size' and 'specified a dimension of 0' are ambiguous. It would be interesting to see if anyone has deliberately made use of the zero argument 'dims...' functionality.
On Tuesday, November 24, 2015 at 4:58:23 PM UTC5, Stefan Karpinski wrote:

Here, me. I am writing dimensionindependent code to define vector spaces, and my tests explicitly include the zerodimensional case. A common syntax is necessary. I think I specified the dimensions as tuple instead of a variable number of arguments, though. erik

Free forum by Nabble  Edit this page 