Feedback on Sealed Types

Brian Goetz brian.goetz at oracle.com
Wed May 1 13:58:12 UTC 2019



> 
>> I kind a like the intellectual separation between 
>> - a sealed interface which represent a closed type and requires a permit clause and
>> - an enum interface which represent a sum type which is sugar on top of sealed interface + records.
> 

To be clear, I think what Alan is suggesting, and what Remi is supporting, is:

 - Make “sealed” the primitive for defining closed types, as originally proposed, and also
 - Make the following 

enumerated interface Foo {
    R(X), S(Y);

    STUFF
}

sugar for

sealed interface Foo
    permits R, S { 

    STUFF

    record R(X) implements Foo { }
    record S(Y) implements Foo { }
}

Is that correct?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190501/df1e80ff/attachment.html>


More information about the amber-spec-experts mailing list