identityless objects and the type hierarchy
John Rose
john.r.rose at oracle.com
Mon Nov 22 05:36:30 UTC 2021
On Nov 4, 2021, at 3:25 PM, Remi Forax <forax at univ-mlv.fr<mailto:forax at univ-mlv.fr>> wrote:
I don't think a second bifurcation is needed.
At runtime bucket 2 and bucket 3 behave the same apart from null.
Given that IdentitylessObject (or whatever the name we choose) is an interface, it always accept null,
so if they are typed as that interface, B2 and B3 behave exactly the same.
Piling on: The marker interfaces are useful for
testing and bounding *reference types*. But
a primitive type is not a reference type, so it
cannot be (directly) tested or bounded as a
reference.
There *is* a difference between a reference
of the form B3.ref (B3.box, B3? whatever)
and B2. But it’s not an interesting difference,
because when you box a B3 primitive you
get something which has (as Brian says)
all the affordances of reference, but
without object identity. That’s exactly
what a B2 type is. The only difference
between a reference to a B3 type and a
B2 type is the syntax by which they were
declared and derived.
This looked pretty clear to me when I
did my diagram, where B3 types have
ref projections that bubble into the
B2 swath of types. Once there, they
behave exactly like native B2 types.
The diagram has three swathes for
concrete types (PRIM, NOID, IDOSAUR),
plus a separate upper quadrant for
non-concrete reference types.
The PRIM swath has a little excrescence
into the NOID swath where the P.ref
types pop out.
http://cr.openjdk.java.net/~jrose/values/type-kinds-venn.pdf
All that suggests to me that we won’t want
a marker interface to specially distinguish the
B3 excrescences.
It does also suggest that we are not done
bike-shedding terms: What’s the collective
term for “B2 refs + B3 boxes”? (I used NOID.)
Or, is a B3 box a “pure object” like any B2
pure object, whose class happens to be a
primitive class? I dunno.
It remains true (and I hope will continue to
be true) that a B3 class defines two types,
one reference and one non-reference, while
a B2 class defines one reference type.
But maybe those two reference types are
both to “pure objects”? I’ll bet Dan has
a take on this.
More information about the valhalla-spec-observers
mailing list