On Mon, Jan 28, 2013 at 11:52 AM, Andreas Rossberg <[email protected]>wrote:
> On 28 January 2013 19:45, Tom Van Cutsem <[email protected]> wrote: > > I just wrote up a strawman on the wiki to summarize the recent debates > about > > the interaction between proxies and private symbols: > > > > http://wiki.ecmascript.org/doku.php?id=strawman:proxy_symbol_decoupled > > > > The page actually lists two proposals, out of which I prefer the second > one. > > > > If I forgot some benefits/drawbacks of either approach, please speak up. > > Under the second approach, how can you transparently proxy an object > with private properties _at all_? It seems like you can't, even when > you have access to its private names. In other words, what do you mean > by "inherit the private state of the target", when the target is still > aliased and accessed? > There is an interesting difference between weakmaps and Tom's second proposal. ----------------------------------------------------- Consider, in proposal #2: // All on the wet side of the membrane. No interesting difference yet var wetRecord = { symbol: PrivateSymbol(), thing: whatever() }; var wetValue = whatever() wetRecord.thing[wetRecord.symbol] = wetValue; // transition to dry side var { wrapper: dryRecord, gate } = makeMembrane(wetRecord); var dryValue = dryRecord.thing[dryRecord.symbol]; // Under proposal #2, dryValue is undefined ----------------------------------------------------- ----------------------------------------------------- Now let's do the "same" thing with WeakMaps: // All on the wet side of the membrane. No interesting difference yet var wetRecord = { symbol: WeakMap(), thing: whatever() }; var wetValue = whatever() wetRecord.symbol.set(wetRecord.thing, wetValue); // transition to dry side var { wrapper: dryRecord, gate } = makeMembrane(wetRecord); var dryValue = dryRecord.symbol.get(dryRecord.thing); // dryValue is a proxy for wetValue ----------------------------------------------------- Conclusion: Although both WeakMaps and Private Symbols have "issues" when virtualized through membranes, WeakMaps virtualize usefully under more scenarios than do Private Symbols under proposal #2. -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

