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.