Axel Rauschmayer wrote:
Value objects are new under the sun. They are not the same as the
primitive AKA value types built into JS. They are typeof-type
"object" but equal by value not reference (under the hood there's a
pointer-compare fast path, of course). They are frozen so you can't
decorate them with expandos to break this equivalence.
More significantly than typeof-type, value objects may be falsy, e.g.
0L and uint64(0). This is a necessary part of the design.
That makes sense. They are very close to primitives. With universal
value object types, one could in principle replace primitives with
value objects (that is neither a suggestion nor a wish of mine ;-).
Continuing the previous idea of a “fixed” typeof as a (shimmable)
function, such a function could return
1. "null"
2. "undefined"
3. "boolean"
4. "number"
5. "string"
6. "value object"
7. "reference object"
That would cover my use cases.
Indeed the primal sin in JS, a combination of "make it look like (and in
Netscape 3 interface with [LiveConnect with] Java)" and me being in a
hurry and taking shortcuts, is primitive types that are not rationalized
up front as objects.
We can fix over time, though. Let typeof wither (it will die hard) and
promulgate a constructor.name-based string-valued "type" function. But
as Allen and I keep saying, avoid the nominal-type-overquerying
anti-pattern, per Smalltalk.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss