Hi,
harmony:weak_maps defines weak maps as "unordered tables mapping objects
to values". It does reminds me objects a lot, but instead of strings,
keys are objects. The API (get/set/has/delete) is very close from what
is already possible with current objects for which we have syntax
constructs for operations basic operations. Could it be considered to
use the object syntax constructs?
Code could look like the following:
----
var wm = new WeakMap();
var o = {};
wm[o] = 123; // set
console.log(wm[o]); // logs 123 // get
if(o in wm){ // has
delete wm[o]; // delete
}
----
There is no new syntax. Everything is already here. There would just be
a need to slighty change relevant semantics:
- MemberExpression : MemberExpression [ Expression ]
(http://es5.github.com/#x11.2.1)
- CallExpression : CallExpression [ Expression
](http://es5.github.com/#x11.2.1)
- - Add branching on baseValue to see if it's an object or weak mapand
behave accordingly.
(equivalent branching for "delete" and "in" operators)
Of course, other objects constructs (for-in loops...) would be
irrelevant in that case.
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss