ceylon/ceylon-spec — Issue #116: Make Sequence<T> a concrete class instead of an interface
Author: gavinking
Created: 2011-12-21 04:45:42+00:00
State: open
Labels: request for feedback

So, after getting a feel for how our APIs are developing, and thinking about the related problems of Java interop and performance, I'm beginning to feel that it might just be more practical to make `Sequence` a class, essentially merging `Sequence` with `ArraySequence` in the language module. This would let us:

* aggressively erase `Sequence` to a Java array,
* provide natural interoperability with Java, and even
* let us aggressively optimize `for` loops over sequences, without the need for use of `instanceof` (a minor nicety).

It would also make me feel a lot more relaxed about and comfortable with the fact that `List`s aren't `Sequence`s as discussed elsewhere.

The downside, obviously, is that you can't provide alternative implementations of `Sequence` to functions which accept `Sequence`. But such functions could always be written to accept `Iterable` instead, where necessary. And frankly, we've already run into this problem if `List` is not a `Sequence`.