records are dead long live to ...
forax at univ-mlv.fr
forax at univ-mlv.fr
Fri Apr 12 16:01:50 UTC 2019
----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Vendredi 12 Avril 2019 16:45:15
> Objet: Re: records are dead long live to ...
>> I believe that since we are exploring the fact that record are immutable, the
>> name "record" doesn't suit well to the feature anymore.
>> I propose to rename it as tuple given that this is what this feature is, named
>> tuples.
>
> It should come as no surprise that we thought about this idea quite a bit.
>
> You have anticipated the main object: "You idiots, these aren't real
> tuples." And the main response: "These are what tuples are in Java".
> (just as lambdas in Java are literals for functional interface
> instances.) It's a believable story.
>
> On the other hand, there's a huge difference between this and lambdas --
> the word "closure" doesn't appear in the source text. if it did, the
> volume of "you idiots, these aren't real closures" would have been much
> greater.
The very same issue exist with the keyword 'record', these are not real records because there are immutable and record are clearly not :)
And i agree that these are not real tuples, they are "named tuples", exactly like the named tuples of Python, that why you have to provide a name after the keyword 'tuple'.
One way to solve that is to replace 'record' by 'named tuple' in the syntax and wait for people to tweet that the keyword 'named' is useless.
>
>
> The real question, in my mind, is how it drives users to the right
> mental model. For those who have no preconceived notions of what tuples
> are, no problem. But for those who do -- and I think that's a lot --
> the question is whether it is more work to unlearn their preconceptions
> first, or to associate what records are with a relatively unpolluted name.
>
> There are two categories of preconceived notions that we're working
> against. One is the larger audience, who has a vague clue about what a
> tuple is, but doesn't have a real axe to grind -- it will be some
> discomfort, but they'll get over it. The other is the smaller but far^3
> more vocal audience -- the Tommy Tuple clan -- who will see it as a door
> permanently slammed on their favorite feature, and it will be Optional
> all over again. And this group may infect the main group.
I think it's exactly the opposite, using 'tuple' is the right name for those who hope to have their favourite structural tuples in the language.
Java type system is nominal, if one want a structural construct in such type system, the construct has to provide a name to please the type system.
For lambdas, the name you provide to the type system is the name of the functional interface found using type inference.
So if we provide named tuples, we are a step in the right direction if the goal is to provide structural tuples, because now you have a name.
Rémi
More information about the amber-spec-experts
mailing list