RefObject and ValObject

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Apr 15 12:20:35 UTC 2019


On 15/04/2019 13:06, Brian Goetz wrote:
>
>
>> But it seems like we have already ruled this out - since, if 
>> typeof(new Object()) is 'RefObject', you don't want RefObject <: Object.
>
> I think you misunderstood the "want" here (though it still may not be 
> possible.)
>
> The desired model is:
>  - Object is the top type.  Everything is an Object.
>  - Some objects have identity (RefObject), others do not (ValObject).  
> But they are all Object.
>
> This means we want {Ref,Val}Object <: Object.  (Whether they are 
> interface or class or something else.)

Seems like I've read this requirement:

"but we don’t want Object <: RefObject for obvious reasons"

backwards. So, what this means is that it would be type-sound regardless 
of interface vs. class choice. But the other concerns remain, e.g. as to 
the fact that the boundary between reinterpreted types (Object as 
RefObject) and non-reinterpreted types (Object as top type) seems very 
fuzzy.

Maurizio

>
> One of the main reasons for wanting this setup is that it reflects the 
> desired reality: everything is an object, but some are special objects 
> (those with identity.)  The addition of value types is a big 
> perturbation to the type system; reflecting it this way makes the 
> object hierarchy reflect the reality and the desired intuition, and 
> makes the distinction between ref/val slightly less magic.
>
> (There are other reasons too; for example, wouldn't it be nice if 
> ValObject.{wait,notify,notifyAll} were _ordinary final methods_ that 
> threw in ValObject?  Again, slightly less magic.)
>
>


More information about the valhalla-spec-observers mailing list