Rationale for Dict?

Brandon Benvie brandon at brandonbenvie.com
Tue Jan 8 12:17:55 PST 2013


To partially answer:

You can use '__proto__' because a dict is basically Object.create(null),
which in ES6 means __proto__ will be just another property. The dict module
also exports entries, keys, and values, so the iteration protocol for a
dict requires using one of those. An example of using dict:

    import { dict, entries } from '@dict';

    const myDict = dict({ a: 10, b: 20, c: 30 });

    for (let [key, value] of entries(myDict)){
      console.log(key, value);
    }




On Tue, Jan 8, 2013 at 3:13 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> Playing devil’s advocate: Is Dict really necessary? Whenever performance
> doesn’t matter (as much), I’d advocate Map. Otherwise, I’d expect
> programmers who want the extra speed to be comfortable with
> Object.create(null).
>
> Assumptions about Dict:
> - You still can’t use the key '__proto__'.
> - You can’t invoke any methods on it.
>
> How will it implement the iteration protocol?
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130108/bcc11e77/attachment.html>


More information about the es-discuss mailing list