It's not safe until it's in the coffer
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed May 8 23:28:41 UTC 2019
----- Mail original -----
> De: "John Rose" <john.r.rose at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Envoyé: Jeudi 9 Mai 2019 00:50:10
> Objet: Re: It's not safe until it's in the coffer
> On May 8, 2019, at 3:12 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>> I propose to use Coffer<Complex> instead of Complex? (with Complex an inline
> So you are giving a name, "Coffer", to the Old Contract.
> The javadoc for the named type-constructor could describe
> this contract fully:
> - array performance profile associated with indirections not inlines
> - non-tearing indirection-based updates
> - null in the value set, if the inline type is already null natively
> - L-descriptors in the JVM (for those who peek)
> - circularities OK (a Foo can have a field of type Coffer<Foo>)
> Maybe Indirect<VT> is the right name, then?
it's better than Coffer.
> The effect of doing this would be to make the indirect version
> of a type VT to look superficially more like a box, at a time
> when we are trying to downplay boxes. But it's only superficial.
> The Coffer/Indirect generic is a one-off type constructor,
> like ? itself. Put another way, matchfix C<.> is just a bulkier
> syntax for postfix-? As such it would have to be documented
> in its essence in the JLS, as well as in its javadoc.
> One consequence of Coffer/Indirect is that it puts a larger
> distance between the two types than VT -vs- VT? does.
> In that, it's sort of like Integer-vs-int. But unlike boxes,
> natural VT operations are not lifted to Coffer<VT>.
> The difference between VT and VT? is small enough
> that I (for one) would expect operations on VT to be
> lifted to VT?. We would also expect a type system
> relation between VT and VT?.
> A consequence of bulkier notation is that it's clear that
> VT <: C<VT> is false. Another is that programmers
> will think twice before saying C<VT> where VT? could be
> an attractive nuisance (like the register keyword).
> So, there are some things to like about this bulky syntax.
> There are lots to dislike:
> - it's bulky (bug or feature?)
> - the nullability is less obvious (but maybe that's not a problem)
> - it's a one-off that has to be defined in JLS and javadoc both
> - it will remind us of wrappers, sometimes
for the nullability, given that Indirect is not an inline class but an indirect class, i don't think this is an issue.
> — John
> P.S. BTW, would Coffer<?> erase to Object?
It can be but i was not able to find that useful given that V is already a subtype of Object and erasing instanceof Indirect<?> to instanceof Object is surprising.
> P.P.S. Must… not… mention… covfefe… argh!!!
i hope my proposal will not gone covfefe :)
More information about the valhalla-spec-observers