ES4 draft LAST CALL: Map

Waldemar Horwat waldemar at google.com
Fri Mar 21 14:05:58 PDT 2008


The current definition in 1.2.2 of what Map(o) does is a harmful dead end.  The current behavior is:

- If o is already a Map then leave it alone.
- Otherwise enumerate the visible properties of o and construct a Map out of those.

This is harmful because it's guaranteed to cause current and future incompatibilities.  There are many other map-like things for which this is the wrong default and we'll be unable to fix them for compatibility reasons.  Here are just a few:

- If you construct a Map out of a Vector, you want the mapping of indices to the elements, with nothing else.  The default behavior brings in extraneous miscellaneous housekeeping properties (length, maybe fixed, perhaps more in the future).
- Folks will write libraries that define MultiMap and Set classes.  We'll want to later allow natural conversion of these to a Map, but the default will get in the way.

For these reasons the current definition of Map(o) is broken and should not be adopted.  The fix is to take out the auto-enumerating behavior.  If it's needed, it should be done by a static function.

    Waldemar



More information about the Es4-discuss mailing list