Yeah, actually, that's roughly what I just ended up doing. I was just playing 
with the idea of creating pollution-free dictionaries using proxies, and came 
up with this:

    https://github.com/dherman/dictjs

The biggest issue, though, is the toString/valueOf one I describe in the other 
message I sent this afternoon.

(Well, that and performance, which quite possibly sucks. So this may not be a 
viable idea. It was an interesting experiment, anyway.)

Dave

On Oct 16, 2011, at 2:49 PM, David Bruant wrote:

> Le 16/10/2011 23:02, David Herman a écrit :
>> Forgive me that I've not kept track of where we are in the discussion about 
>> the additional receiver argument.
>> 
>> I think I just found a pretty important use case for the receiver argument. 
>> Say you want to keep some information about a proxy object in a Map or a 
>> WeakMap, and you want the handler to be able to access that information. 
>> Then you're going to need the proxy object to do it.
>> 
>> I suppose you can close over the proxy value:
>> 
>>    var proxy;
>>    var handler = { ... proxy ... };
>>    proxy = Proxy.create(handler);
>> 
>> But then you have to make a fresh handler for each instance.
> Also, a temporary solution to have access to the proxy without is being
> an argument is to put it as a property of the handler. Example:
> https://github.com/DavidBruant/HarmonyProxyLab/blob/master/LazyReadCopy/LazyReadCopy.js#L84
> 
> Actually, an object is created with the handler as prototype. this
> object gets an own "proxy" property and this is the object that is used
> as handler. I think that Tom gets credit for this idea.
> 
> David

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to