Sealed types
Brian Goetz
brian.goetz at oracle.com
Fri Dec 7 18:43:39 UTC 2018
> Maybe "permits" -> "exclusivelyIncludes" or just "exclusively"? These
> seem less likely to be misinterpreted and also less likely to lead to
> any confusion with not-rare use of "permits" as a variable (in
> semaphores etc).
Good thought.
> Is there any reason except convenience to use the implicit version for
> classes in the same unit? You'd guess that without it, IDEs would soon
> offer to help fill in the lists.
>
It’s convenience for sure, but users might well think it’s a little
excessive to have to say:
|final interface Node permits IntNode, PlusNode, MulNode, NegNode,
ParenNode { } record IntNode(int value) implements Node; record
PlusNode(Node left, Node right) implements Node; record PlusNode(Node
left, Node right) implements Node; record NegNode(Node node) implements
Node; record ParenNode(Node node) implements Node; |
When the whole sum-of-products is this compact, saying “IntNode” twice
will feel like the same sort of Java verbosity everyone complains about.
And in typical Visitor situations, there are more than a handful of
subtypes, meaning that the “permits” clause will be pretty long.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20181207/375589a1/attachment.html>
More information about the amber-spec-experts
mailing list