Le 4 août 2013 à 18:23, Brendan Eich <[email protected]> a écrit :

> 
> You must mean by 'objectness' reference-not-value semantics -- typeof 
> returning "object" or "function" and the user ruling out null value (or 
> opting into "null" result) doesn't do a thing to reject non-extensible, 
> no-own-property objects of course.
> 
> /be


There is a problem of terminology about what is called "object", and it will 
lead to confusions if not amended:

* For some technically reasonable definition of "object", Value Objects are 
objects.
* But for most programmers grown in a world where there is only Primitives and 
non-Value Objects (let's call them "Reference Objects"), Value Objects are 
better classified in the group of Primitives than in the group of Objects.

The reason is that Value Objects share the following features with Primitives, 
which constitute the practical important differences between them and Reference 
Objects:
* intrinsically immutable, with no own property;
* comparing by value.
The fact that Value Objects does not need wrapper in order to act like an 
object is an implementation detail that has almost no practical significance in 
the day-to-day life of the programmer (well, true, it will not break 
`instanceof`...).

Incidentally, the fact that `typeof` evaluates to "object" for most Reference 
Objects but for almost no Primitives, reinforces the association of the word 
"object" to Reference Objects.

In this very thread, there have been at least three people in three days who 
have spontaneously called "object" things that are exclusively Reference 
Objects, although the very subject of this thread tells loudly that there is 
another kind of objects:
* myself: https://mail.mozilla.org/pipermail/es-discuss/2013-August/032545.html 
(where `Object.isObject()` ruled out Value Objects in my meaning);
* Brandon Benvie: 
https://mail.mozilla.org/pipermail/es-discuss/2013-August/032553.html (where 
"objectness" rules out Value Objects);
* Bruno Jouhier: 
https://mail.mozilla.org/pipermail/es-discuss/2013-August/032561.html (where 
"objects (mutable)" is in contrast to "values (immutable)")

One radical solution is to revise the definition of "object", so that Value 
Objects are not objects. For example, what is currently called "object" would 
be named "thingummy", while the label "object" would roughly apply to 
intrinsically mutable, compare-by-reference thingummies.

Another less radical thing to do, is to de-emphasise the notion of "object" 
from the API, by excluding things like `Object.isObject` (programmers need 
rather `!Object.isValue`, anyway).

—Claude


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to