Calling toString on function proxy throws TypeError exception

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Oct 26 19:20:54 UTC 2015


> On Oct 26, 2015, at 11:20 AM, Mark Miller <erights at gmail.com> wrote:
> 
> I like the idea a function proxy is more encapsulating of its implementation than a function is.
> 
> I also like the idea of treating a function proxy as a builtin callable, rather than a function written in JS, and return something like "function () { [function proxy] }" as Tom suggested or "function () { [native code] }" as Claude suggested. We need progress on the draft spec for F.p.toString reform, including the standardized pattern for the function sources that are not supposed to parse, e.g., "function () { [...stuff...] }”.

I guess I still don’t understand the use case for applying there built-in F.p.toString to any callable.  If you are explicitly defining a callable proxy you may want to define a `toString` method for it that does something that makes sense for the specific kind of callable you are creating. But when you expect to do:

```js
   evalableString = Function.prototype.toString.call(anyOldCallable);
```

with the expectation that the result you are going to get will be useful for anything?

Allen



More information about the es-discuss mailing list