A few questions and suggestions.

Peter Hall peter.hall at memorphic.com
Mon Apr 30 10:22:34 PDT 2007

> a) Currently, firefox returns "{[native code]}" for native function
> bodies when using toSource(). AFAIK the meaning of the "source"
> property is to return the actual source of the function. Even if
> native bodies can't be returned, I think it's awkward to return a
> string that is not syntax valid:
> eval(eval.toSource()); //syntax error!
> Is it appropriate to specify that native functions should return
> syntax valid code (in this case, a comment "/* native code */" could
> be used, instead)?

Even better would be to return some source that just invoked the same
function. For example, eval.toSource() would return "/* native
function */ return eval(str);":

Then you could eval it, as you describe, and not only would it not
throw an error but it would run as expected too...


More information about the Es4-discuss mailing list