Calling toString on function proxy throws TypeError exception
Tom Van Cutsem
tomvc.be at gmail.com
Fri Oct 23 08:16:31 UTC 2015
2015-10-22 23:09 GMT+02:00 Allen Wirfs-Brock <allen at wirfs-brock.com>:
>
>
> 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`
>
Calling Function.prototype.{call,apply,bind} on a function proxy should
obviously work (not throw a TypeError), as a function proxy has
well-defined behavior in such cases. For toString(), the two obvious
choices are to forward (show the function body of the target function), or
to generate a custom toString() representation like other exotic objects do
(e.g. "function () { [function proxy] }", or perhaps even show the
toString() representation of the apply trap).
Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151023/cd53547d/attachment.html>
More information about the es-discuss
mailing list