Ok, but there doesn't seem to be any way to say "only value classes can extend 
me!”

At some level, this is a matter of taste and return-on-complexity.  Obviously 
this is not _needed_, but some programmers are clearly comforted by the ability 
to capture this intent.  Of course, adding such restriction adds complexity at 
every layer; it needs a syntactic expression, it needs a clasfile 
representation, it needs static type checking, it needs dynamic enforcement, it 
needs reflection, etc.  So the first question is: does the incremental 
expressiveness justify the incremental complexity?

But more importantly, as Remi points out, seemingly harmless “intent capturing” 
things at the source level can turn into unexpected difficulties for longer 
term issues such as migration compatibility.  We saw a similar example of this 
in Java 8, where people asked “why can’t I make a default method final”, but 
then when you show them the impossible problems this creates for subclasses, 
they change the subject.  Foreclosing on possibilities like this, that are 
often “over the maintenance horizon”, are often “shallowly sensible” but make 
the ecosystem brittle.

Reply via email to