>From a user perspective, I'm really happy to see WeakMaps in the
proposals. The syntax for it deviates from js' currently cohesive core
object model, though; requiring getter and setter methods and having no
literal format.
One alternative that may work neatly is a 'hold me weakly' operator. For
example's sake, I'm going to use *, but there may be other eligible ones:
*As a key*:
var key = {}
, obj = { *key: 'val' } // when `key` is eligible for GC, the key:value
pair gets deleted
obj[key] // -> 'val'; retrieval by `key` doesn't require the operator
*As a value*:
var val = {}
, obj = { key: *val } // likewise, when `val` is eligible for GC, the
key:value pair gets deleted
*As both a key and a value*:
var val = {}
, key = {}
, obj = { *key: *val } // when *either* `key` or `val` is eligible for
GC, the key:value pair gets deleted
*Non-literal form*
var key = {}
, val = {}
, obj = {}
obj[*key] = *val // behaves the same as obj = { *key: *val }
I'm almost 100% convinced that the reason type of thing isn't in the
proposal is that there's a some glaring semantic or implementation issue;
but I thought it'd be worth mentioning anyway. If not only because of the
comparative neatness of the syntax, perhaps also for helping keep the
language cohesive as it grows.
Best,
Hugh
--
Hugh Jackson: Web Development
Mobile: 0797 609 1579
Email: [email protected]
Code: github.com/hughfdjackson
Twitter: @hughfdjackson
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss