Are Private name and Weak Map the same feature? and the Assoc API
rossberg at google.com
Wed Dec 21 03:06:24 PST 2011
On 19 December 2011 16:56, Tom Van Cutsem <tomvc.be at gmail.com> wrote:
> I think I don't have a problem with widening the type of the name parameter
> of all of these traps from String to Object. Then a proxy handler can at
> least test whether it is intercepting a private name or a normal property.
Widening the "type" seems like the only coherent solution to me. In
the presence of private names, a property name simply isn't a string
anymore, but string|private_name. Consequently, on reflective
boundaries, if you want to protect privacy, that turns into
> The only thing I'm worried about at this point is that there has to be a
> simple way for the proxy to say "I'm not interested in intercepting this
> private name, just forward it to my target". Otherwise I'm afraid most
> proxies will wrongly forward a private name access as a normal property
Indeed, that looks like a problem.
I think your idea points in the right direction. In fact, there is no
reason to make it specific to private names, it might be useful for
public properties, too. Instead of simply having all-or nothing traps,
and making it the responsibility of each trap to forward unwanted
cases properly, allow traps to signal "I don't care, please forward"
on a per-property basis.
Unfortunately, I don't have a good suggestion for a convenient
interface, besides introducing a sentinel value that traps can return
(I am still puzzled how people can survive in dignity without variants
and tuples... :) ).
More information about the es-discuss