Strengthening Function.prototype.toString

Karl Krukow karl.krukow at
Sat Sep 27 09:18:48 PDT 2008

A summary of the discussion.


-- current large implementations already satisfy this. I've tested it  
on: Firefox 2, Firefox 3, Safari 3.2.1, IE6, IE7, the latest Opera,  
SquirrelFish Extreme, TraceMonkey and V8.

-- It is powerful. When combined with a parser like Crockford's one  
can use some powerful meta-programming techniques commonly only found  
in languages like Scheme and LISP.

-- It should not be that hard to implement.


-- There are some smaller implementations which do not satisfy this  
semantic property.

--  It would perhaps add more complexity to implementations and it is  
hard to test true equality of functions so you would have to prove it  
correct ;-)

-- It would require implementations to keep a decompilable version of  
the function around. This may not be appropriate for implementations  
running on memory-constrained devices.

I would really like to stay on track, discussing whether or not it is  
a possible addition to 3.1. Are the pros outweighing the cons?

To extend section Function.prototype.toString ( )
with something similar to the following paragraph.

For any function f and any values x1, x2, ... , xn, whenever  
eval(f.toString()) is called in the same scope f was defined, we have

eval(f.toString())(x1,x2,...,xn) === f(x1,x2,..., xn).


More information about the Es-discuss mailing list