[External] Foo / Foo.ref is a backward default; should be Foo.val / Foo
forax at univ-mlv.fr
forax at univ-mlv.fr
Mon Apr 25 20:36:45 UTC 2022
> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Dan Heidinga" <heidinga at redhat.com>, "Kevin Bourrillion"
> <kevinb at google.com>, "valhalla-spec-experts"
> <valhalla-spec-experts at openjdk.java.net>
> Sent: Monday, April 25, 2022 9:54:26 PM
> Subject: Re: [External] Foo / Foo.ref is a backward default; should be Foo.val /
> Foo
>> This seems very specific to Optional, for Optional storing null is always a
>> mistake, but that's not true for other VBC, by example a deadline can be typed
>> as an Instant with null meaning no deadline.
> No, it is not specific to Optional at all. Many domains exclude null on an
> ad-hoc basis.
> It is about giving the user the choice to reserve space in the heap for the null
> or not. If other logic has already excluded null (which is common), they can
> use an Instant.val and get better footprint. If they like the semantics of
> having null, they can use Instant.
As the maintainer of Instant, you do not want people to be able to misuse your API, if you declare Instant as a B3, then they will see the tearing, so you will declare it as a B2 so the whole point of having B3 being a ref by default is moot.
Optional is special not only because null make no sense but also because it's size is small enough to be loaded/stored in one (micro-)instruction.
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/valhalla-spec-experts/attachments/20220425/5b261e61/attachment.htm>
More information about the valhalla-spec-experts
mailing list