A few questions and suggestions.
Brendan Eich
brendan at mozilla.org
Mon Apr 30 10:32:08 PDT 2007
On Apr 30, 2007, at 10:22 AM, Peter Hall wrote:
>> 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...
You can't eval a return statement or any such statement illegal in
the top level of a Program (the non-terminal goal for the grammar
that eval parses).
/be
More information about the Es4-discuss
mailing list