where are all the objects?
Robbe Pincket
robbepincket at live.be
Tue Jul 19 15:28:27 UTC 2022
On Wed Jul 13 20:54:43 UTC 2022, John Rose wrote:
> I’m using a more neutral term "realize" instead of "instantiate".
I'm not really a fan of the term, I see why "instantiate" doesn't fit, but I hope stuff will be able to get reworded in such a way that "realize" isn't needed.
> These propositions seem to be all true (“at least” in part):
> - The result of realizing at least some classes in some types is, in fact, an "object".
> - The result of realizing at least some classes in some types is, in fact, an "instance" of that class.
> - The result of realizing at least some classes in a value type is a "value" of that class.
> - Every variable "has a value".
> - Every reference, other than `null`, "refers to an object".
> - Every non-reference variable “contains a value” (as well as having it).
I'm very confused what you mean with your last point. "Every non-reference variable “contains a value” (as well as having it)". A variable is a typed storage location, a variable containing a value or a variable having a value are in my mind synonyms. But if I read your point, it sounds like you disagree and a non-reference (primitive?) variable has and contains 2 (different?) values?
---
On Thu Jul 14 16:48:00 UTC 2022, Kevin Bourrillion wrote:
> The instances of a value type are "values".
> The instances of a reference type are "references to objects".
> [...]
> But primitive values are instances too. Of primitive types. I think that has always been true (though most of us aren't in the habit of saying it, because they were never *class instances* which is a very useful kind).
Oh god, no no no no no nooo. The instances of a reference type are the objects, not the references to those objects. The references are the values that a variable of a compatible type can hold. And no one calls primitive values instances, is cause they aren't. All mentions of "instances" in Java spec refer to "class instances" or "instances of a/the class" (at least as far I can see).
> An object | A value
> ----------------------------- | -----------------------------------------
> has independent existence | is ephemeral (no existence of its *own*)
> is self-describing | is context-described
> is accessed via reference | is used directly
> is eligible to have identity | can’t have identity
> is polymorphic | is strictly monomorphic
> has the type `Object` | does not have the type `Object`
I agree with some of these but I have a few issues:
* I feel like independent existence and identity are the same thing, how would you be able to differentiate 2 equal objects that don't have identity?
* I think I understand what you mean with "self-describing", if I have an object, I expect to be able to call `.getClass`. As a result an object holds all the info to fully interpret the object. But I'm missing something with "context-described". It feels like you are saying a value needs a context to "exist", but values are ephemeral. They just exist.
In the end, I don't think "object" and "value" are mutually exclusive. Anything that extends Object is an "object", anything that is ephemeral is a "value" and anything that is both is a "value object" (identityless object)
> I would say that arrays are also instances -- of array types. What they aren't is *class* instances. (So they don't get to have members; `length` and `clone` are at best half-heartedly-simulated members.)
Arrays do have members, all the methods of `Object` are inherited by arrays, `clone` being one of them.
---
John:
> Even if we give up on making everything an object, I will still request that we cling to *some* word that can uniformly be applied to the result of realizing *any Java class*. If that word is not "object" I think it is "instance".
Kevin:
> Yes, I think it is absolutely and usefully "instance".
> A tough spot about my model (which I think is unavoidable/acceptable) is that I can't get away with saying "An object is any class instance or array" anymore.
Yeah this a bit of a nuisance. It would be nice to have a term that covers both "values" and "instances", because in my mind, and instance is something that gets instantiated. Ephemeral values don't get instantiated, cause they exist. Which means with my view objects of value classes aren't instances (?? this surprised me, but I can't convince myself otherwise anymore).
Regards
Robbe Pincket
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-observers/attachments/20220719/6b560c4c/attachment.htm>
More information about the valhalla-spec-observers
mailing list