This issue is that this point of view suggests that x
and Ref(x)
should behave the same, ie that collect(x) == collect(Ref(x))
. But while that’s true for numbers, it’s not true when x
is a collection like [1,2,3]
or "abc"
. The counterargument is that this behavior is uniquely useful for array indices but that argument feels very thin to me.
As an experienced user, I sometimes really like this behaviour. But I have team members who complain about this too, and I totally agree that it is a bit quirky, and wouldn’t mind if it went away.
As an aside, I don’t think it would be fair to claim that this behaviour is derived from a linear algebraic understanding of numbers. There seems to be very little linear algebra that goes into iteration schemes of other objects. The iteration scheme of a matrix, for example, is derived from the memory layout of the object. On the other hand, if numbers were truly regarded as how one would typically understand them in a linear algebra context, they would be operators and closer in equivalence to a UniformScaling
, which, by the way, does not support iteration . However, as I recall, treating numbers as operators in a linear algebra context was met with a lot of opposition in discussions pre-1.0, and, although I used to be in favour, I’m now happy that it wasn’t implemented