Good point, that's definitely a usable solution (also a better representation of what I was attempting to describe).
I'd still be interested in a less-verbose/more-efficient approach using the Symbol constructor, but it may not be a common enough scenario to justify it when a workaround does exist. On Fri, Jul 12, 2013 at 3:32 PM, Allen Wirfs-Brock <al...@wirfs-brock.com>wrote: > > On Jul 12, 2013, at 12:14 PM, Jeremy Martin wrote: > > In brief: allow Symbol's to be constructed with a single parameter, with > the following behavior: > > > var obj = {}; > undefined > > new Symbol({}) === new Symbol({}) > false > > new Symbol(obj) === new Symbol(obj) > true > > > You can use a WeakMap to build your own object-selected Symbol factory: > > let known = new WeakMap; > > function ObjSymFactory(obj) { > //handle obj === undefined however you want > let sym = known.get(obj); > If (!sym) { > sym = new Symbol; > known.set(obj,sym); > } > return sym; > } > > Allen > > > -- Jeremy Martin 661.312.3853 http://devsmash.com @jmar777
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss