Constructing records through reflection and module restrictions
Brian Goetz
brian.goetz at oracle.com
Sun Dec 8 15:50:43 UTC 2024
Sure, there are other ways we could have designed the language. Tuples
are structural types, which means they are not declared, but instead
spring when the type constructor is applied to other (necessarily
accessible) types. This means there is no need for access control, since
anyone who can access T and U can "summon" the type `tuple<T,U>`. (We
have this for arrays already -- which is already a significant source of
irregularity in the language, so we chose not to emulate that.)
But, we chose to lean into Java's class-based, nominal type system.
Making special exceptions "because it's like a tuple" is surely
convenience in some cases, but makes the language more complicated to
reason about overall.
On 12/8/2024 10:15 AM, Florian Weimer wrote:
> It's the syntactic overhead. The attractiveness of this pattern is
> that's it's a clear and concise notation for this type of
> deserialization. Creating a public type for it in a suitable package
> sort of breaks that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20241208/324de5ea/attachment-0001.htm>
More information about the amber-dev
mailing list