Lifting the restriction on the number of public classes per file
brian.goetz at oracle.com
Tue Nov 27 19:27:30 UTC 2018
> Will imports always be necessary when pattern matching on sealed types,
> or could there be something like the provision for enum switches?
We could expose a model where a sealed nest is more like an enum, and
the nest members are more like enum constants, in which case using the
same rules as for enums would make sense. If we thought that was the
right model for sealing. If we end up not relaxing the rules regarding
aux classes, we should consider this for switches (but it doesn't really
address the more general API design question.)
It is true that in many other languages, sealed types are mostly
intended for "sums of products", which is a reasonable 80/20 target.
Though I'd rather see a deeper / more orthogonal treatment (though that
does force us to work through more details.)
> The hardest downside to the proposal
There's not a proposal, yet... There's just a discussion, proximately
motivated by an external comment, but one that has been on the drawing
board for a while, since we started to look at more concise ways to
express sum and product types.
More information about the amber-spec-experts