I would like to express my strong support for the proposal.
Building on the proposal, Olof Karlsson, a former student of mine, implemented extensible records and performed a comprehensive experimental evaluation, comparing with (1) old-style structural types, (2) case classes, (3) trait fields, (4) Shapeless, and (5) Compossible.
You can find the full results in the following paper:
Olof also gave a talk about this work at Scala Symposium '18:
What’s exciting about our records design is that it supports width and depth subtyping as well as type-safe extensibility also in a polymorphic context, using context bounds. Example:
def center[R <: Record : Ext["x",Int] : Ext["y",Int]](r: R) = r + ("x", 0) + ("y", 0)
Here, the context bound : Ext["x",Int]
expresses the requirement that it is safe to extend a record of type R
with an “x” field of type Int.
Right now, our implementation requires a small extension of Dotty which synthesizes instances of an Extensible
type class, which is used in the above context bound using the Ext
type lambda:
type Ext[L <: String, V] = [R <: Record] => Extensible[R, L, V]
Our records implementation easily supports more than 200 fields (important in some enterprise settings), in a scalable way, outperforming even case classes in some benchmarks (with more than 60 fields). See the above paper for microbenchmarks as well as a case study parsing JSON-encoded commit events from the GitHub API into typed records and processing them.
Implementation of the Dotty extension:
The performance evaluation uses a new benchmarking source code generator, called Wreckage, built on top of the JMH microbenchmarking harness: