Calling toString on function proxy throws TypeError exception
allen at wirfs-brock.com
Thu Oct 22 21:09:25 UTC 2015
> On Oct 22, 2015, at 1:38 PM, Tom Van Cutsem <tomvc.be at gmail.com> wrote:
> I cannot recall any specific discussions on why that behavior was changed to throwing a TypeError instead. The only reason I can come up with is that it could be deemed a violation of the proxy's encapsulation in that it should not leak such details about its target object.
> I think it would be useful to at least reconsider the original forwarding behavior. I think that in practice, forwarding toString() to the target is not harmful, and the more places where code throws on a Proxy, the less useful Proxies become altogether.
> I noticed there is a stage 1 proposal to revise the specification of F.p.toString() <https://github.com/michaelficarra/Function-prototype-toString-revision <https://github.com/michaelficarra/Function-prototype-toString-revision>>, including standardizing its behavior for host objects. Perhaps the behavior of F.p.toString() when applied to (function) proxies can become a part of this revision effort?
Why would it be reasonable to do this for `toString`, but not also `call`, `apply`, and `bind`? And ultimately this problem exists for all built-in methods that have have internal state dependencies. I just don’t see why we care so much specifically about `toString`
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss