Strengthening Function.prototype.toString

Eugene Lazutkin eugene.lazutkin at gmail.com
Fri Sep 26 23:58:03 PDT 2008




Karl Krukow wrote:
> 
> However I would have to move from a form:
> 
> (function(a,b) {return a+b;}).specialize({ a: 42})
> 
> to
> 
> (function(a,b) {return a+b;}).specialize([42])

Does your example substitute a or b? How to indicate what parameter(s)
you want to specialize?

Another thing: your solution relies on keeping around potentially big
function bodies in their textual form, and a full-blown parser (+
interpreter, if you want to do optimizations while specializing) written
in JavaScript, while there is a parser already in the
compiler/interpreter that is a part of a run-time (see eval()). Sounds
complicated, resource-hungry, and redundant. Why not implement
specialize() at the interpreter/compiler level rather than hacking
around with toString()? If we are to ask for features let's ask big! ;-)

Thanks,

Eugene




More information about the Es-discuss mailing list