A few questions and suggestions.

Peter Hall peter.hall at memorphic.com
Mon Apr 30 10:35:52 PDT 2007


ok, in that case it doesn't make much sense to do any work to support
evaling any source string from toSource().

Peter


On 4/30/07, Brendan Eich <brendan at mozilla.org> wrote:
> 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
>
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>



More information about the Es4-discuss mailing list