Why not private symbols?

Erik Arvidsson erik.arvidsson at gmail.com
Fri Aug 2 13:25:06 PDT 2013


On Fri, Aug 2, 2013 at 4:02 PM, Domenic Denicola
<domenic at domenicdenicola.com> wrote:
> I know the answer will be obvious when I see it, but I can't quite remember ... why is it important that `O[privateSymbol]` not invoke the proxy?

We don't want to leak the privateSymbol to a proxy.

module 'foo' {
  var privateSymbol = ...;
  export function tag(object) {
    object[privateSymbol] = true;
  }
  export function hasTag(object) {
    return !!object[privateSymbol];
  }
}

If someone passes a proxy into tag/hasTag the privateSymbol object
must not be passed to the proxy handler.

-- 
erik


More information about the es-discuss mailing list