<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">On 13 Jul 2022, at 13:23, John Rose wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;">
<p dir="auto">…Another result of backing away from “primitive” is that we have to engage with the question of “where are the objects?”  Obviously every non-null value of a variable whose type is an identity class refers to “an object”.  But beyond that it gets dicey and we will have to adjust our agreements, I think.  This is probably worth a separate thread, which I will start, and which I expect Kevin will be very interested in.</p>
</blockquote>
<p dir="auto">A class defines ways to “realize” the class in its types, that is, in variables of its companion types.</p>
<p dir="auto">Examples:  <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">C r = new C();</code> and <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">C.val v = C.default;</code> and <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">new C.val[1]</code>.</p>
<p dir="auto">(For class declared non-atomic, races can also “realize” values of the class.)</p>
<p dir="auto">I’m using a more neutral term “realize” instead of “instantiate”.  You can think “instantiate” or “construct” if you like.  A long-winded way to say “realize a class” without tripping over words I want to avoid is “make a non-<code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">null</code> runtime configuration of a variable of a type of that class, using, directly or indirectly, an expression allowed by the declaration of that class”.</p>
<p dir="auto">These propositions seem to be all true (“at least” in part):</p>
<ul>
<li>The result of realizing at least some classes in some types is, in fact, an “object”.</li>
<li>The result of realizing at least some classes in some types is, in fact, an “instance” of that class.</li>
<li>The result of realizing at least some classes in a value type is a “value” of that class.</li>
<li>Every variable “has a value”.</li>
<li>Every reference, other than <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">null</code>, “refers to an object”.</li>
<li>Every non-reference variable “contains a value” (as well as having it).</li>
</ul>
<p dir="auto">So, do we think they are true?  And of which classes, and for which of their companion types, are they true?</p>
<p dir="auto">I think some of us would like to reserve the term “object” for something that has a header and a storage block in the heap.  Although talking about memory blocks and headers and machine pointers is probably illegitimate for a JVMS, it is semi-transparent enough to “see” that stuff like that is going on.  (Except when it isn’t:  Both Valhalla flattened references and classic escape analysis break those intuitions.)  Users will want <em>something</em> to visualize about objects, and maybe that just doesn’t jibe with how we want them to think about values.</p>
<p dir="auto">OTOH, it is really freeing to be able to say that “every class makes objects”, and build from there into a world of “identity objects” and “value objects”.</p>
<p dir="auto">(I can also appeal to various C standards, in which everything is either an object or a function.  Yes, a C <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">int</code> is a C object.  Take that, Mr. Objects-Are-Everywhere Java.  That might work for us too with minor adjustments.)</p>
<p dir="auto">Even if we give up on making everything an object, I will still request that we cling to <em>some</em> word that can uniformly be applied to the result of realizing <em>any Java class</em>.  If that word is not “object” I think it is “instance”.</p>
<p dir="auto">Also I think it is still useful to at least pretend (virtually) that a reference is always to an object.  So, something like this:</p>
<ul>
<li>
<p dir="auto">The result of realizing any class in its reference companion is an object of that class.</p>
</li>
<li>
<p dir="auto">The result of realizing any class into any of its companion types is an instance of that class.</p>
</li>
<li>
<p dir="auto">The result of realizing any value class into its value companion is a “value” of that class.</p>
</li>
<li>
<p dir="auto">Maybe also: The result of realizing any value class into its reference companion is a “value” of that class (as well a an “object” of that class).</p>
</li>
<li>
<p dir="auto">Every variable “has a value”.  (Same as above.)</p>
</li>
<li>
<p dir="auto">Every reference, other than <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">null</code>, “refers to an object”.  (Same as above.)</p>
</li>
<li>
<p dir="auto">Every non-reference variable “contains a primitive” or “contains an instance”.</p>
</li>
<li>
<p dir="auto">Any value is (therefore) either a primitive, an instance, a <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">null</code> reference, or a reference to an object.</p>
</li>
<li>
<p dir="auto">An object (therefore) is an instance or an array.  (Cribbing from Kevin here.)</p>
</li>
<li>
<p dir="auto">By an abuse of language, it is common to ignore the reference part of a reference variable, and say that it “has” or “contains” an instance if not <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">null</code>.  (This makes opportunities for consistent reasoning about <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">C.ref</code> and <code style="margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7;">C.val</code> variables.)</p>
</li>
</ul>
<p dir="auto">Get those spray-paints shaking!  Bonus points if we finish before Brian gets back from his vacation, he’ll be so pleased!</p>

</div></div></body>

</html>