Sealed types
Doug Lea
dl at cs.oswego.edu
Sun Dec 9 13:36:08 UTC 2018
On 12/9/18 8:28 AM, Remi Forax wrote:
> 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.
I just noted that ":" is available. So are others with "" prefix: ":>",
"::", etc that would avoid this.
>
> 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.
>
That's why it would be better to allow either names or full definitions.
-Doug
> 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-experts
mailing list