Strengthening Function.prototype.toString

Maciej Stachowiak mjs at
Fri Sep 26 02:13:01 PDT 2008

On Sep 26, 2008, at 12:38 AM, Karl Krukow wrote:

> My suggestion is to strengthen the contract to state something like:
> For any function f and any values x1, x2, ... , xn we have:
> eval(f.toString())(x1,x2,...,xn) === f(x1,x2,..., xn).

I would agree with such a requirement, but only in the case where the  
eval(f.toString()) is performed in the same scope where f was  
originally defined, since toString does not represent the scope chain.

Note however, that this still allows for some quite significant  
rewrites of the function body, so it might still not be very  
interoperable to rely on parsing and modifying the toString result.


More information about the Es-discuss mailing list