On Tuesday, July 15, 2014 3:10:50 AM UTC-4, Sheehan Olver wrote: > > > > I noticed that deepcopy of a vector doesn't know that the result is the > same type. Regular copy does, see below. Is this intentional or a bug? > > It looks to me like this is the reason
function _deepcopy_array_t(x, T, stackdict::ObjectIdDict) if isbits(T) return copy(x) end dest = similar(x) stackdict[x] = dest for i=1:length(x) if isdefined(x,i) arrayset(dest, deepcopy_internal(x[i], stackdict), i) end end return dest end But I wonder could it be redefined to: *function _deepcopy_array_t{T}(x::Array{T}, t::Type{T},stackdict::ObjectIdDict)* * if isbits(t)* * return copy(x)* * end* * dest = similar(x)* * stackdict[x] = dest* * for i=1:length(x)* * if isdefined(x,i)* * arrayset(dest, deepcopy_internal(x[i], stackdict), i)* * end* * end* * return dest* *end*