Data Oriented Programming, Beyond Records

Archie Cobbs archie.cobbs at gmail.com
Wed Jan 21 19:59:23 UTC 2026


On Wed, Jan 21, 2026 at 1:34 PM Brian Goetz <brian.goetz at oracle.com> wrote:

> If you read the spec for Record::equals, you'll see that this invariant
> -- take it apart with accessors, put it back together unchanged with the
> constructor, the result must be equals() -- is written into the Record
> spec.  Not because we chose to "generate" equals and hashCode, but
> because of what the "just" in "just a carrier for S" means.
>

That's a good requirement, and I agree that identity equality is wrong for
records and carriers, but there was another way we could have achieved this
requirement, i.e, by using value equality (i.e., using == on each
component) instead of recursive equality (using equals() on each component)
or identity equality (using == on this & that).

Asking in another way, how would you describe the conceptual distinction
between a record and a value class?

Thanks,
-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20260121/2a43564f/attachment.htm>


More information about the amber-spec-experts mailing list