Superclasses for inline classes

John Rose john.r.rose at oracle.com
Fri Dec 20 01:05:10 UTC 2019


On Dec 18, 2019, at 3:57 PM, Dan Smith <daniel.smith at oracle.com> wrote:
> 
> abstract superclasses

A quick observation:  The Panama Vector API uses interfaces to abstract
from specific vector types, and those specific vector types must be made
inline to enable full optimization.

For example: Float128Vector <: FloatVector <: Vector<Float> <: Vector<?>

In this scheme we either need to seal FloatVector to Float128Vector
and its siblings, or else we need to do something with abstract classes.
There may be incremental benefits to making FloatVector be an
abstract class, such as being able to define and document toString,
equals, and hashCode.

If in addition we could define FloatVector as an abstract *inline* class,
we might benefit from the effect of FloatVector being non-nullable.
The top-level interface Vector<Float> would still be nullable.

The plan of record is to make every vector type be either an interface
or an inline, and then move to specialized interfaces and inlines when
templates become available.  But Vector is one place where abstract
classes are worth a serious look.

— John


More information about the valhalla-spec-observers mailing list