On Wed, Oct 19, 2011 at 9:52 AM, Axel Rauschmayer <[email protected]> wrote:

> 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; // undefinedtypeof table; // "dict"
>
> This example misses the key point: The [] and . namespaces must not
overlap.  For example:
  table["foo"]; // "howdy"
not affected by the delete table.foo.


> Problem: How do you invoke methods on table?
>

table.tellAxel = function() {alert('here is a method call');};
table['tellAxel'] = function() {alert('here is a function entry");};
table.tellAxel();  // here is a method call
table['tellAxel'].apply(null,[]);  // here is a function entry


> 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.
>

Yes, that is exactly the point.

jjb


> 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

Reply via email to