On 28/04/2022 14:51, Kevin Bourrillion wrote:

    If we ride with that horse, it means that in universal generics,
    we should not use T but T.val apart when we want T.val | null that
    can be spelled T.


I'm not following, but again I think I'm naively assuming a type variable might need to be projected in either direction.

In my opinion, this does represent a change that is "less syntactic" than it looks.

Saying "T.ref" means "give me the reference projection of T". Reference projections are defined for both reference classes (String.ref = String) and for value classes (of course!).

By analogy, saying "T.val" means "give me the value projection of T". But here we have an issue: while value classes do have value projections (again, of course!), reference classes do not.

This seems to be at odds with the "for all" semantics of type-variables.

What we need to make "for all" works is a function that gives us the value projection _if it exists_, or the type unchanged otherwise.

T.valOrT

Naming asides (this is a bikeshed that will be painted later), one thing stands: this is no longer a "projection", this feels like a more ad-hoc type mapping (and one which might be a bit hard to explain).

Maurizio

Reply via email to