What is an Object Type(O)?
kangax at gmail.com
Sat Mar 7 11:32:15 PST 2009
On Mar 7, 2009, at 1:53 PM, Allen Wirfs-Brock wrote:
> Your understand in your last paragraph is correct.
> In general, the term “type” used in the specification is referring
> to the categorization of values defined in Section 8. One of those
> “types” is “object”. Functions are values of the object type. The
> section 5.2 definition of Type(x) is correct but perhaps should be
> elaborated upon as: Type(x) is shorthand for “the type of x” where
> possible types are those defined in Section 8 (ie, Undefined, Null,
> Boolean, String, Number, Object, Reference, List, Completion,
> Property Descriptor, Property Identifier, Lexical Environment, and
> Environment Record).
> Note that there are very few cases where a value might be either one
> of the “ECMAScript language types” (the first 6 types in the list
> above) or one the “specification types” (the rest of them) so most
> often Type(x) predicates in the specification is just choosing from
> among the language types.
This explains it perfectly! Thank you.
> The actual coding of this test is obviously implementation dependent
> and I’m not familiar with your specific implementation so I can’t
> say whether or not the functions you showed are correct.
My initial test tries to rule out exactly all of the "ECMAScript
language types" except an Object one - Undefined, Null, Boolean,
String and Number. I think of these types as of "primitives",
therefore `isPrimitive` function name : ) If a value passed to
`Object.keys` is in a subset of these "language types", then my test
should work properly. If, on the other hand, a value is one of the
"specification types" - there will be false positives. From what I
understand, I shouldn't worry about specification types, as none of
them seem to be able to make its way as an argument of `Object.keys`.
Am I correct?
> I’ll think about whether or not I can easily clarify this in the
> specification. I’ve always found to definition of Type(x) to be
> obscure and hard to find.
That could be beneficial for other people having same doubts as I have
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Es-discuss