Seeing a sequence as an assignment from integers to elements is only one way to describe what a sequence is. There are other ways, and there is no reason why that way of describing a sequence should become canonical. The actual purpose of a sequence is to make a bunch of elements accessible and traversable. A sequence is not required to actually assign integer numbers to the elements. For example, most Stream
implementations probably don't have a counter running in parallel to the traversal. Requiring that would impose an unnecessary overhead on the implementation.
Besides, a Map[K,V]
is also an Iterable[(K,V)]
. Following your suggestion, a Seq[A]
would also have to be a Map[Int,A]
, which would by that also make it an Iterable[(Int,A)]
. Since Seq
extends Iterable
, this would make the Seq[A]
both an Iterable[A]
and an Iterable[(Int,A)]
(and, recursively, an Iterable[(Int,(Int,A))]
, Iterable[(Int,(Int,(Int,A)))]
, and so on), which is not an allowed way of inheritance in Scala.
You can construct a similar argument for your suggestion regarding Set
.