Getters vs. public final fields in records

Brian Goetz brian.goetz at oracle.com
Sat Aug 13 19:25:31 UTC 2022


The definition of the approximation ordering <= is part of the e-p pair, 
along with the two sets being related and the two mappings.  You've 
chosen a different <= for each of R and S; in R-land, you say that true 
approximates everything; in S-land, you say that false approximates 
everything.  That's why you got the seeming inconsistency.

In any case, we're getting pretty far afield and I'm still not getting 
any closer to seeing the point you're trying to make, other than "I 
don't like how you designed records, and I think my idea is better, and 
I want to argue about it."  Which is (a) not the charter of this list, 
(b) arguing about decisions that are already made, and (c) does not seem 
to be offering any new information about why your way is better that 
wasn't already in evidence when the feature was being designed.  So I 
think we're kind of off the road here.



On 8/13/2022 2:20 PM, Andrew Cave wrote:
>
>
>     Except you've got your mappings the wrong way around.
>
>
> Ok, let’s go with that:
>
> (new R(a)).p() <= a
>
> It’s difficult to be precise, because you haven’t spelled out the 
> entire semantics (and I’m pretty sure it doesn’t exist), but, if we 
> are able to do some kind of “normalization”, we are presumably able to 
> do the simplest imaginable kind:
>
> record R(Boolean b) {
>   Boolean b() { return true; }
>   bool equals(Object o) { return true; }
> }
>
> And also:
>
> record S(Boolean b) {
>   Boolean b() { return false; }
>   book equals(Object o) { return true; }
> }
>
> from which we can deduce:
>
> false = S(true).b() <= true
>
> And
>
> true = R(false).b() <= false
>
> So true <= false and false <= true, hence true = false, and since you 
> interpret “=“ as .equals, we are forced to make .equals() on Boolean 
> say that true is equal to false.
>
> The key here is that <= in “R(a).p() <= a” is the one defined on the 
> domain (type) of *a* and you don’t get to choose what it is as part of 
> the definition of your record; it’s already chosen for you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20220813/c192cbe5/attachment.htm>


More information about the amber-dev mailing list