Variants/case classes/algebraic data types/sums/oh my!

Brian Goetz brian.goetz at oracle.com
Sun Jun 12 15:46:26 UTC 2016


> I think the bulk of it was being able to specify in class metadata that
> a class/interface is sealed (perhaps just ACC_SEALED) and that it has a
> given list of immediate child classes (we don't need to talk about the
> entire set of descendants of a class, as implementing matching seems
> to only require going one inheritance step deep at a time). This
> seems to be covered in a more general form in the nestmates proposal, so
> maybe I won't actually need to implement much!
>
>

The nestmate proposal doesn't (yet) discuss sealing in detail, but the 
concept is pretty simple: sealing is a generalization of finality which 
says "may only be extended by members of the same nest."  Since nests 
will probably map 1:1 to compilation units, this covers most ADT 
situations pretty cleanly.  Extending sealing to interfaces is an 
additional step, but works the same way -- we have to insert the word 
"direct" into the rule ("may only be *directly* implemented by members 
of the same nest".)  There are some more details to work out, of course, 
but this is just to say that nestmates enable sealing in a fairly 
straightforward way.





More information about the valhalla-dev mailing list