title: Julia: rational behind array size and index for "extra" dimensions?
body: <p>I am using Julia from time to time, however I am surprised by the following behavior:</p>
  
  <p>Let's define an 3x4 array</p>
  
  <pre><code>julia&gt; m=rand(3,4)
  3×4 Array{Float64,2}:
   0.889018  0.500847  0.539856  0.828231 
   0.492425  0.582958  0.521406  0.754102 
   0.28227   0.834333  0.669967  0.0939701
  </code></pre>
  
  <p>Now I check that</p>
  
  <pre><code>julia&gt; size(m,1), size(m,2)
  (3, 4)
  </code></pre>
  
  <p>as expected.</p>
  
  <p><strong>However, I am surprised by this:</strong></p>
  
  <pre><code>julia&gt; size(m,3), size(m,2018)
  (1, 1)
  </code></pre>
  
  <p>-> I would have expected <code>(0,0)</code> or an <code>error message</code></p>
  
  <p>Looking the Julia code confirms this behavior:</p>
  
  <pre><code>size(t::AbstractArray{T,N}, d) where {T,N} = d &lt;= N ? size(t)[d] : 1
  </code></pre>
  
  <p><strong>Moreover</strong>:</p>
  
  <pre><code>julia&gt; m[2,1,1,1,1]
  0.4924252391289974
  </code></pre>
  
  <p>-> I would have expected an <code>out of bounds error</code></p>
  
  <p><strong>So my question is: "what is the rationale?"</strong>
  ( I do not thing it is a bug, I use Julia version 0.6.2)</p>