Action proxies

David Bruant bruant.d at
Sun Feb 3 07:22:41 PST 2013

Le 03/02/2013 01:59, Mark S. Miller a écrit :
> Hi David, have you seen 
> ?
I remember seeing the announcement, but I must have forgotten about it. 
My bad :-s

> AFAICT, this provides the same flexibility as action proxies with 
> hardly any more mechanism and overhead than bare notification proxies. 
> The key is that, if the pre trap returns a callable, the proxy calls 
> that callable after the action as a post trap. No need to reify an 
> action thunk, ever, though in exchange the pre trap must often 
> allocate the post trap it returns.
Either allocate or keep the post-trap around for reuse, but yes.
On the post trap of getOwnPropertyDescriptor and keys, I would pass an 
iterator as argument, because it is not sure the post-trap will actually 
look at the result, so no absolute need to re-allocate the array. Or 
maybe wrap the array in a (built-in) readonly proxy (throws on writing 
Speaking of iterator, if the enumerate pretrap returns an iterator with 
an editable "next" method, can the post-trap modify the next method? 
Maybe there is some necessary wrapping in that case too.

> Is there any remaining advantage of action proxies over this?
Trap names don't start with "on"? :-) I don't think the "on" is 
absolutely necessary, but that's more of a style issue. Otherwise, I 
don't think so. Unless I'm overlooking something, I think there is the 
following equivalence:

     // action proxy:
     trap: function(){
         // pre-trap code
         // post-trap code

     // notification proxy:
     trap: function(){
         // pre-trap code
         return () =>{
             // post-trap code

The post-trap code is optional in the former part equivalently to the 
return statement in the latter.

This does indeed get rid of invariant checks while guaranteeing the 
invariants anyway and apparently not losing expressiveness. Wow.

Was this discussed during the January TC39 meeting? Do notification 
proxies have a chance to replace direct proxies or is it too late?
In the case it would be too late, could "throw ForwardToTarget" be 


More information about the es-discuss mailing list