Question about universal type variables
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Aug 3 17:53:41 UTC 2022
On 27/07/2022 23:25, Dan Smith wrote:
> I'm not*totally* sure I grasp all the differences, but here are a couple of observations that seem to support Model 2:
I'm not sure I grasp the differences between model 1 and 2 either.
But if by Model 1 you simply mean that a type-variable is a place holder
that the compiler knows nothing about, then I believe that model to be
not an accurate description of what happens.
For instance, a type variable still as _members_ and, because of that,
it _has_ to be a type (at least in JLS-land). Note that, even in
System-F, type-variables have _bounds_, so they are not mere
placeholders and you can reason about (some of) their properties.
That said, a type-variable, even today, does not expose all the
properties of regular types. For instance, members of type-variables are
defined in a different ways (e.g. by filtering out public members), and
a type-variable cannot be the target of a cast (module warnings), or an
instance test (modulo errors) expression.
In the same way, universal type-variables cannot answer the question of
"are you a ref or a val" (in the same way in which today's type variable
cannot answer the question of: are you an Integer or a Double).
Maurizio
More information about the valhalla-spec-observers
mailing list