Claude Pache wrote:
Le 4 août 2013 à 01:39, Brendan Eich<[email protected]>  a écrit :

Brendan Eich wrote:
Claude Pache wrote:
Fixing `typeof` of old (null) and new value types would be a solution, but I'm 
rather definitely considering something like the defunct `Object.isObject()`
I forgot to add that my patch for 
https://bugzilla.mozilla.org/show_bug.cgi?id=749786 includes

Object.isObject(x) // false unless x is an object
Object.isValue(x)   // true for primitives and value objects

The idea: isObject returns true for all the new value object types and the 
reference-semantics objects found in JS today, while isValue returns true for 
all compare-by-value types, whether the legacy primitives (undefined, null, 
boolean, number, string) or the new-in-ES7 value objects.

/be

Ok. What I am most interested, when I test for an "object", is roughly that I 
am able to get or set properties on it (ignoring restrictions or special cases like 
freezing, etc., and, in order to shorten the test, forgetting functions that are not 
supposed to occur).

Value objects are non-extensible, no-own-property (so effectively frozen), compare-by-value objects.

  Or that it can be used like an object created by `new Object` (an 
Object-like). This probably coincides with `!Object.isValue`. Likely, I won't 
want to treat `1L` like `{ }` and differently from `1`.

Right, you want !Object.isValue(x).

That numbers are non-objects but int64 are objects is much more an 
implementation detail than a relevant distinction for the programmer.

Yes, that's intentional. I'm not sure we need the Object.is{Object,Value} APIs but they might be handy. Could go in the to-be-named Reflect module instead.

So, I consider that `typeof int64(0) === "object"` and your `Object.isObject` are about 
as useless than `typeof null === "object"`.

You could be right -- if it's useless we should cut it. But it does provide a bit of information that's not the same as !Object.isValue, and which is a bit clumsy to piece together otherwise.

/be

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

Reply via email to