Julia function argument by reference : <p>The docs say</p>

<blockquote>
  <p>In Julia, all arguments to functions are passed by reference.</p>
</blockquote>

<p>so I was quite surprised to see a difference in the behaviour of these two functions:</p>

<pre><code>function foo!(r::Array{Int64})                                                                                                                                                                                     
        r=r+1                                                                                                                                                                                                      
end


function foobar!(r::Array{Int64})                                                                                                                                                                                  
        for i=1:length(r)                                                                                                                                                                                          
                r[i]=r[i]+1                                                                                                                                                                                        
        end                                                                                                                                                                                                        
end 
</code></pre>

<p>here is the unexpectedly different output:</p>

<pre><code>julia&gt; myarray
2-element Array{Int64,1}:
 0
 0

julia&gt; foo!(myarray);

julia&gt; myarray
2-element Array{Int64,1}:
 0
 0

julia&gt; foobar!(myarray);

julia&gt; myarray
2-element Array{Int64,1}:
 1
 1
</code></pre>

<p>if the array is passed by reference, I would have expected foo! to change the zeros to ones.</p>
