-
Notifications
You must be signed in to change notification settings - Fork 219
Description
I'm adding modifiers to platform classes.
I'm generally adding base
to things like SetBase
, ListMixin
or UnmodifiableListView
because they are not intended as interfaces to implement. (If you ever want to do implements SetBase
, someone missed a point somewhere, either you or someone whose code you need to interact with. Just use implements Set
.)
However, since base
makes every subclass not have an implementable interface, I cannot do something like:
class SuperSet<T> extends SetBase<T> {
// More great APIs on top of `Set`, and this is the default implementation.
}
and allow someone to implements SuperSet
.
Instead I have to do
abstract interface SuperSet<T> implements Set<T> {
// More great APIs ....
}
// and
base/*or final*/ class SuperSetImpl<T> extends SetBase<T> implements SuperSet<T> {
// Implementation of the great APIs.
}
That's not necessarily bad, but it does force a separation into interface and implementation that Dart has so far not forced.
The obvious alternative is to not make SetBase
be base
. It's not dangerous if someone implements SetBase
, it's just unnecessary and confusing.
What would work better is the ability to make SetBase
not introduce an implementable interface, but not force it to be inherited by subclasses.
Strawman: A modifier called "nointerface" which allows the same direct operations as base
(aka: not implement), but does not force subtypes to be base
or final
.
Because sometimes that's all you want to say: "This type is not important, always use the supertype instead, or an important subtype."