We could have traits instead of interfaces, while still allowing "trait inheritance". This would mean classes and structs can explicitly implement a trait internally, while also allowing external "extension" of types with traits. e.g.
trait Iterator!(T, TState) {
TState InitialState ();
T? TryGetNext (ref TState state);
}
extends IList!(T) with Iteratable!(T, intN) {
intN InitialState => 0;
T? TryGetNext (ref intN index) => index < length ? this[index] : null;
}
class ClassWithIterator : Iterator<T, int32> {
// [...]
}
We could have traits instead of interfaces, while still allowing "trait inheritance". This would mean classes and structs can explicitly implement a trait internally, while also allowing external "extension" of types with traits. e.g.