On Mon, Feb 15, 2016 at 1:43 AM, Andreas Rossberg <rossb...@google.com> wrote:

> Without wanting to say much on the overall viability of your plan, but
> proxies do work with `with`. However, your code has at least two bugs:
>
> (1) It's not defining a custom `has` trap. That is needed for `with`,
> otherwise it will just check the target object, which has no `f`.
>
> (2) You cannot return `console.log` first-class and expect it to work (at
> least not on all browsers). Known JavaScript issue.
>
> This fixed version works fine on V8 4.9 / Chrome 49:
>
> function f() { console.log("failure") }
>
> let p = new Proxy({}, {
>   has() { return true },
>   get() { return x => console.log(x) }
> });
>
> with (p) { f("success") };
>
> /Andreas

Thank you very, very much!  I feel embarrassed I missed that it needed
a has(), but I am glad I have a solution that works now - I thought it
impossible!
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to