iteration order for Object

David Bruant bruant at enseirb-matmeca.fr
Fri Mar 11 08:27:19 PST 2011


Le 11/03/2011 17:13, John Lenz a écrit :
> This whole discussion makes reminds me how much JavaScript needs
> proper collections.  People use "Object" but they don't really want
> Object (where prototype properties leak into data, where they String
> is the only key type, where the strings "1.0" and "1" can not be
> represented in the same map, etc) they want a HashMap, a
> LinkedHashMap, a Set, etc.   
Proxies will allow to implement all of that and more.

Back to the initial use case, the only thing proxies do not allow to do
is capturing property order of object literals.

>
> On Fri, Mar 11, 2011 at 7:48 AM, Charles Kendrick
> <charles at isomorphic.com <mailto:charles at isomorphic.com>> wrote:
>
>     On 3/11/2011 7:35 AM, Wes Garland wrote:
>
>         Someone -- Mark Miller? -- suggested an interesting option
>         when this discussion came up last on
>         this list (around Christmas 2010 IIRC).  Basically --
>         enumerate named props in insertion order,
>         and numeric props in numeric.   This gets pretty close to what
>         most developers seem to expect,
>         while leaving the door wide open for fast implementation of
>         array-like objects.
>
>
>     Just connecting the dots - I addressed this in my first email on
>     the subject.  While it superficially sounds like a good
>     compromise, I actually think it's the worst possibility: it
>     requires browser vendors to implement limited order preservation,
>     preventing deeper optimizations like sorted keys.  At the same
>     time, it requires that applications and frameworks deal with lack
>     of order for numeric keys, which are very common: in the use case
>     of mapping stored to displayed values, stored values are very
>     often numeric.
>
>     I also think that it's surprising and counter-intuitive that
>     numeric keys are treated differently from non-numeric.  The
>     reality is that an implementation detail of Array is bleeding
>     through to Object.
>
>     _______________________________________________
>     es-discuss mailing list
>     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>     https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> _______________________________________________
> 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/20110311/d9d16342/attachment.html>


More information about the es-discuss mailing list