Should `collect` also be deprecated, like `full`?


#1

I’m very glad to see full deprecated: I was never sure what exactly it meant, whereas Matrix(...) is unambiguous.

Does the same argument apply to collect? For example, I’m surprised the following returns an Array (in 0.6):

julia> collect(CartesianRange(CartesianIndex((1,1)), CartesianIndex((2,2))))
2×2 Array{CartesianIndex{2},2}:
 CartesianIndex{2}((1, 1))  CartesianIndex{2}((1, 2))
 CartesianIndex{2}((2, 1))  CartesianIndex{2}((2, 2))

Insisting on the use of Array/Vector/Matrix instead of collect seems more explicit and predictable.


#2

Yes, there is work in progress towards that. See https://github.com/JuliaLang/julia/issues/16029 and recent development of https://github.com/JuliaLang/julia/issues/11557


#3

FWIW, I often collect in order to sort.


#4

You’d call sort(Vector(itr)). That’s actually a good example why collect is currently flawed: if it returns a matrix then calling sort will fail.


#5

Or sort could collect automatically when needed, so we would just have to sort(itr).