It starts with a bang ends with a quote

forax at univ-mlv.fr forax at univ-mlv.fr
Tue May 21 15:29:59 UTC 2024


> From: "daniel smith" <daniel.smith at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Sent: Tuesday, May 21, 2024 4:49:30 PM
> Subject: Re: It starts with a bang ends with a quote

>> On May 21, 2024, at 1:09 AM, Remi Forax <forax at univ-mlv.fr> wrote:

>> Hello,
>> I recently tried to convince myself that using a type annotation (the bang '!')
>> was the best way to do type specialization at langage level but I still find it
>> awkward.

>> There are several reasons why using a bang to ask for type specialization does
>> not work well with the rest of the design of value types.

> We've considered lots of different variations on specialization, so to be clear:
> you're critiquing an approach in which Foo<Val!> is specialized, while
> Foo<String> and Foo<Val> are not. Is that right?

Not exactly, I think we do not need Foo<Val!> at all. 

> I think we're going to end up with a stronger requirement: that Foo<Val!> and
> Foo<Val> must *both* be specialized. (My inclination has always been to throw
> Foo<String> in there, too, but that one is more negotiable.)

> Why specialize Foo<Val>? Because we can often still flatten the storage (we're
> including some flattening of nullable value class types in JEP 401), and in any
> case we should always scalarize specialized method signatures for value class
> types.

I will go a step further, by example, in most case an immutable list rejects null, so a list created with ImmutableList via List<Val>.of() should be specialized, it's up to the implementation of ImmutableList to decide which kind of storage to use. So it's not something a user should control, thus no List<Val!>, List<Val> is enough. An for the scalarization, i hope that Val + requireNonNull is enough (we can speculate of the fact that a value type is non null). 

Rémi 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-observers/attachments/20240521/be6709b2/attachment.htm>


More information about the valhalla-spec-observers mailing list