<p dir="auto">The docstring for <code class="notranslate">convert</code> is wonderfully explicit about providing details about the underlying assumptions in many cases, but I've found one that isn't yet covered. <code class="notranslate">convert(T, x)</code> has the behavior that if <code class="notranslate">x</code> already has type <code class="notranslate">T</code>, we just return <code class="notranslate">x</code>. But for AbstractArrays, things get more complicated:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; A = rand(3,5)
3×5 Array{Float64,2}:
 0.324103  0.45017   0.469432  0.382722  0.241098 
 0.336333  0.481648  0.165303  0.616973  0.0452947
 0.567737  0.964775  0.82846   0.300232  0.140285 

julia&gt; pointer(A)
Ptr{Float64} @0x00007fad96e33ba0

julia&gt; pointer(convert(Array, A))
Ptr{Float64} @0x00007fad96e33ba0

julia&gt; S = view(A, :, :)
3×5 SubArray{Float64,2,Array{Float64,2},Tuple{Colon,Colon},true}:
 0.324103  0.45017   0.469432  0.382722  0.241098 
 0.336333  0.481648  0.165303  0.616973  0.0452947
 0.567737  0.964775  0.82846   0.300232  0.140285 

julia&gt; pointer(convert(Array, S))
Ptr{Float64} @0x00007fad970d8e20"><pre class="notranslate">julia<span class="pl-k">&gt;</span> A <span class="pl-k">=</span> <span class="pl-c1">rand</span>(<span class="pl-c1">3</span>,<span class="pl-c1">5</span>)
<span class="pl-c1">3</span><span class="pl-k">×</span><span class="pl-c1">5</span> Array{Float64,<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-c1">0.324103</span>  <span class="pl-c1">0.45017</span>   <span class="pl-c1">0.469432</span>  <span class="pl-c1">0.382722</span>  <span class="pl-c1">0.241098</span> 
 <span class="pl-c1">0.336333</span>  <span class="pl-c1">0.481648</span>  <span class="pl-c1">0.165303</span>  <span class="pl-c1">0.616973</span>  <span class="pl-c1">0.0452947</span>
 <span class="pl-c1">0.567737</span>  <span class="pl-c1">0.964775</span>  <span class="pl-c1">0.82846</span>   <span class="pl-c1">0.300232</span>  <span class="pl-c1">0.140285</span> 

julia<span class="pl-k">&gt;</span> <span class="pl-c1">pointer</span>(A)
Ptr{Float64} @<span class="pl-c1">0x00007fad96e33ba0</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">pointer</span>(<span class="pl-c1">convert</span>(Array, A))
Ptr{Float64} @<span class="pl-c1">0x00007fad96e33ba0</span>

julia<span class="pl-k">&gt;</span> S <span class="pl-k">=</span> <span class="pl-c1">view</span>(A, :, :)
<span class="pl-c1">3</span><span class="pl-k">×</span><span class="pl-c1">5</span> SubArray{Float64,<span class="pl-c1">2</span>,Array{Float64,<span class="pl-c1">2</span>},Tuple{Colon,Colon},<span class="pl-c1">true</span>}<span class="pl-k">:</span>
 <span class="pl-c1">0.324103</span>  <span class="pl-c1">0.45017</span>   <span class="pl-c1">0.469432</span>  <span class="pl-c1">0.382722</span>  <span class="pl-c1">0.241098</span> 
 <span class="pl-c1">0.336333</span>  <span class="pl-c1">0.481648</span>  <span class="pl-c1">0.165303</span>  <span class="pl-c1">0.616973</span>  <span class="pl-c1">0.0452947</span>
 <span class="pl-c1">0.567737</span>  <span class="pl-c1">0.964775</span>  <span class="pl-c1">0.82846</span>   <span class="pl-c1">0.300232</span>  <span class="pl-c1">0.140285</span> 

julia<span class="pl-k">&gt;</span> <span class="pl-c1">pointer</span>(<span class="pl-c1">convert</span>(Array, S))
Ptr{Float64} @<span class="pl-c1">0x00007fad970d8e20</span></pre></div>
<p dir="auto">In the first case we didn't copy, in the second we did. Often there is no choice but to copy, for example if we had defined <code class="notranslate">S = view(A, 1:2, 1:3)</code>; however, in cases like <code class="notranslate">view(A, :, :)</code> it would be possible to return the original without making a copy (and it wouldn't violate type-stability).</p>
<p dir="auto">An even more intermediate case comes from array types like</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct MyArray{T,N} &lt;: AbstractArray{T,N}
    data::Array{T,N}
end"><pre class="notranslate"><span class="pl-k">struct</span> MyArray{T,N} <span class="pl-k">&lt;:</span> <span class="pl-c1">AbstractArray{T,N}</span>
    data<span class="pl-k">::</span><span class="pl-c1">Array{T,N}</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">For this type, <code class="notranslate">convert(Array, A::MyArray)</code> could <em>always</em> return <code class="notranslate">A.data</code> directly. But is this advisable? Or should it be a copy any time <code class="notranslate">typeof(A) != T</code>?</p>
<p dir="auto">Consider:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function foo(x)
  y = convert(Vector{Float64},x)
  y[1] = 10.0
  return y
end
julia&gt; x = [1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia&gt; foo(x)
3-element Array{Float64,1}:
 10.0
  2.0
  3.0

julia&gt; x
3-element Array{Int64,1}:
 1
 2
 3

julia&gt; x = [1.,2.,3.]
3-element Array{Float64,1}:
 1.0
 2.0
 3.0

julia&gt; foo(x)
3-element Array{Float64,1}:
 10.0
  2.0
  3.0

julia&gt; x
3-element Array{Float64,1}:
 10.0
  2.0
  3.0"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">foo</span>(x)
  y <span class="pl-k">=</span> <span class="pl-c1">convert</span>(Vector{Float64},x)
  y[<span class="pl-c1">1</span>] <span class="pl-k">=</span> <span class="pl-c1">10.0</span>
  <span class="pl-k">return</span> y
<span class="pl-k">end</span>
julia<span class="pl-k">&gt;</span> x <span class="pl-k">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Int64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">1</span>
 <span class="pl-c1">2</span>
 <span class="pl-c1">3</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">foo</span>(x)
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Float64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">10.0</span>
  <span class="pl-c1">2.0</span>
  <span class="pl-c1">3.0</span>

julia<span class="pl-k">&gt;</span> x
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Int64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">1</span>
 <span class="pl-c1">2</span>
 <span class="pl-c1">3</span>

julia<span class="pl-k">&gt;</span> x <span class="pl-k">=</span> [<span class="pl-c1">1.</span>,<span class="pl-c1">2.</span>,<span class="pl-c1">3.</span>]
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Float64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">1.0</span>
 <span class="pl-c1">2.0</span>
 <span class="pl-c1">3.0</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">foo</span>(x)
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Float64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">10.0</span>
  <span class="pl-c1">2.0</span>
  <span class="pl-c1">3.0</span>

julia<span class="pl-k">&gt;</span> x
<span class="pl-c1">3</span><span class="pl-k">-</span>element Array{Float64,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">10.0</span>
  <span class="pl-c1">2.0</span>
  <span class="pl-c1">3.0</span></pre></div>
<p dir="auto">The input is modified in one case, and not the other, which is in the realms of "scary". One (The?) solution is to always do a copy, even if the type matches, for mutable types.</p>