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

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.

1 Like

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

1 Like

FWIW, I often collect in order to sort.

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.

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

2 Likes