[External] : Re: User model stacking

Brian Goetz brian.goetz at oracle.com
Thu Apr 28 13:43:59 UTC 2022



On Apr 28, 2022, at 9:09 AM, Remi Forax <forax at univ-mlv.fr<mailto:forax at univ-mlv.fr>> wrote:
1/ There is a difference between Foo and Foo.ref for generics, Foo is a class while Foo.ref is a type.
    The idea of using Complex.val means that the relationship is reversed,
     Complex is the type and Complex.val is the class.

This is simply wrong.

Classes and types are separate things; declaring classes gives rise to types.  The class is Complex, in both cases.  In both cases, it gives rise to two types, which might be denoted Complex.ref and Complex.val, or one of which might be also called Complex.  But just because they have the same name, doesn’t change what they are.  Classes != types.  The class is Complex.  Always.

I think most of the other points depend on this misconception, but I’ll skip to ….


 4/ It's a double opt-in, people have to opt-in at declaration site by asking for a zero-default value type but that is not enough,
     it only works if the type val is uses at use site. I don't know any feature in Java that requires a double opt-in.

To say “it doesn’t work” is like saying “I have a sink with hot and cold taps, I turned on the cold tap, and no not water came out, this sink doesn’t work.”  The declaration site enables the existence of the hot water tap; whether you turn it or not is your choice.

I think what 4/5 are trying to get at is “it feels like too much ceremony to have to say something at both the declaration and use sites in order to get full-flat vals.”

This is a valid opinion!  But its also pretty obvious that this is a potential concern, so I’m  not sure what you’re getting at by raising it in this way (supported by the preceding misguided arguments?)

      5/ It's easy to forget a ".val". To work, people will have to pepper .val everywhere and it will be easy to miss one occurrence.
     Depending on where the ".val" is missed, performance will suffer.

I think this is your whole point: “people will have to type .val a lot, and they might miss one”, right?

This is exactly the sort of argument I was talking about by “let’s not try to jump to the end and design the final syntax immediately.”  As should be clear, a lot of thought has gone into teasing out the elements of the model; give yourself some time to internalize them.





More information about the valhalla-spec-observers mailing list