> What are you suggesting? A new primitive? Or a subtype of Object? I don’t > think there is a third alternative to those two. > > I am suggesting that typeof return "collection" when the RHS defines a new > semantic for [] (collection properties) and . (object properties).
Currently you have either primitives or objects. Primitives get methods from their wrapper types. And I think this dichotomy has served JavaScript very well. Redefining . in a hypothetical collection primitive would have the following problem. For example, dicts [1] are used as follows. var table = [foo: "howdy", 42: true, "hey, cool!": "not bad, huh?"]; table["foo"]; // "howdy" delete table.foo; table.foo; // undefined typeof table; // "dict" Problem: How do you invoke methods on table? Using AWB’s terminology, accessing properties is part of the program definition domain, accessing collection elements is part of the application data domain. And it’s better not to mix the two. If you look at Java Maps, the separation becomes clear: You use methods to add new collection elements, but have to way to dynamically change the shape of a Map instance. [1] http://wiki.ecmascript.org/doku.php?id=strawman:dicts [D.H. already mentioned that this proposal does not reflect his current thinking, so beware] -- Dr. Axel Rauschmayer [email protected] twitter.com/rauschma home: rauschma.de blog: 2ality.com
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

