> From: "John Rose" <john.r.r...@oracle.com> > To: "daniel smith" <daniel.sm...@oracle.com> > Cc: "Remi Forax" <fo...@univ-mlv.fr>, "valhalla-spec-experts" > <valhalla-spec-experts@openjdk.java.net> > Sent: Thursday, January 27, 2022 2:18:03 AM > Subject: Re: The interfaces IdentityObject and ValueObject must die !
> On 26 Jan 2022, at 16:36, Dan Smith wrote: >> An instance of a class is also an instance of (and carries the properties of) >> its superclasses. Value objects are instances of the class Object. >> I can imagine a design in which we say that instances of Object may be either >> identity or value objects, but direct instances of the class are always >> identity objects. But this is not how we've handled the property anywhere >> else, >> and it breaks some invariants. We've gotten where we are because it seemed >> less >> disruptive to introduce a subclass of Object that can behave like a normal >> identity class. > And yet there is also a second way a class can be an instance; it can be > exactly > an instance of C , when x.getClass()==C.class . That’s the condition which can > be teased apart here, if we allow ourselves to use something other than marker > interfaces. But marker interfaces (as I said) are committed to ignoring the > “exactly an instance” condition, because they inherit. YES ! being a value class (primitive class) is a runtime property, not something attached to a type and this is a separate concern from the flattenability which is either type hint (Q-type, L-type + Preload) or a type hint + a runtime check in case of arrays. Rémi