Make records not implicitly final

Samuel Andrés samuel.maurice.andres at gmail.com
Tue Feb 11 00:52:38 UTC 2020


Hi Rémi,

Thank you very much for answering with some explanations. I focused on 
implementation. But Records combined with interface hierarchy is 
definitely the good way to address the kind of issue I was talking 
about. I'm confused... oops ! Thanks a lot !

Best regards.

Samuel

Le 10/02/2020 à 21:48, Remi Forax a écrit :
> ----- Mail original -----
>> De: "Samuel Andrés" <samuel.maurice.andres at gmail.com>
>> À: "amber-dev" <amber-dev at openjdk.java.net>
>> Envoyé: Samedi 8 Février 2020 17:45:46
>> Objet: Make records not implicitly final
>> Hi to all,
>>
> Hi Samuel,
>
>> I hope this is the correct place for comment about Records.
>>
>> I saw discussions about extension of records here (
>> https://cr.openjdk.java.net/~briangoetz/amber/datum.html ) leading to
>> the conclusion that "we should hold this possibility in reserve". I
>> understand the main reasons to make records implicitly final and not
>> extensible.
>>
>> Nevertheless, stuctures like records could also be very useful for
>> modelling purposes if they would be extensible.
> Hum, modelling doesn't require inheritance.
>
>> May be the usage could lead to a compromise on this point (for 
>> example, generating default
>> equals() / hashCode() implementations, only for explicitly final
>> records, using all the members of the parent class hierarchy). I am not
>> a language specialist, but I share my point of view, just in case...
> We had a kind of similar discussion (you can browse the spec-expert 
> list for more info).
> The idea is that you don't need inheritance to be able to specify that 
> several "structures" share the same components, an interface is enough.
> So instead of
> abstract record Base(int age) {}
> final record Person(String name, int age) extends Base(age) {}
>
> you can write
> interface Base {
> int age();
> }
> record Person(String name, int age) implements Base {}
>
> This avoid to introduce the concept of abstract record (or its dual 
> final record) in the language which is a huge win in term of simplicity.
>
> [...]
>
>> Thanks for reading. I'm sorry for my bad english.
>>
>> Samuel Andrés
> regards,
> Rémi





More information about the amber-dev mailing list