Sealed types
Remi Forax
forax at univ-mlv.fr
Sun Dec 9 13:28:29 UTC 2018
Hi Doug,
using colon ':' will cause trouble to people that discover Java after having used C or C# given that ':' is used to introduce supertypes in those languages.
Your proposed compact declaration is a mess visually if you declare a subtype which is a sealed interface with a list of subtypes, because it becomes a tree.
Rémi
----- Mail original -----
> De: "Doug Lea" <dl at cs.oswego.edu>
> À: "Brian Goetz" <brian.goetz at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Dimanche 9 Décembre 2018 14:16:47
> Objet: Re: Sealed types
> On 12/7/18 1:43 PM, Brian Goetz wrote:
>>> 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.
>
> The main thought is to clarify that these are exclusive/complete types,
> as used in UML etc requirements.
>
> There are also some syntax holes that don't even need reserved words.
> Colon+parenthesized list seems OK:
>
> final interface Node : (A, B, C) { ... }
>
> ... and would allow even more compact declaration if the list elements
> could be either names or full definitions:
>
> final interface Node : (
> record IntNode(int value),
> record PlusNode(Node left, Node right),
> record NegNode(Node node)
> ) {
> public void evaluate();
> }
>
> -Doug
More information about the amber-spec-observers
mailing list