Sealed types
Brian Goetz
brian.goetz at oracle.com
Tue Jan 8 18:52:09 UTC 2019
>
> Or, if not additive, but we end up reusing the `final` keyword in the
> way shown at the bottom of this email, then we could at least allow
> `permits /<bikeshed>/, TypeA, TypeB` which is maybe nearly as good.
In light of this morning's observation about hyphenated keywords ...
there's a lot in this thread about why it seemed more attractive to
retcon final for sealed-ness rather than create a new conditional
keyword. But it was a bit confusing (because final already has
associations), and we ran into the problem that
final class X { }
already means something, which deprived us of the opportunity to infer a
permits clause. Switching to something derived from `final` (such as
`semi-final`) restores that, while keeping the associations with final:
semi-final class A
permits X, Y, Z { ... }
non-final class X extends A { ... }
class Y extends A { } // implicitly final
semi-final class B
/* inferred permits clause */ { ... }
I think this is the best of both worlds; we clearly connect to finality,
but don't directly overload it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190108/6381c46b/attachment.html>
More information about the amber-spec-experts
mailing list