In what ways does the following "eval" regularity break?
erik.arvidsson at gmail.com
Thu Oct 30 10:07:51 PDT 2008
2008/10/30 Brendan Eich <brendan at mozilla.com>:
> On Oct 29, 2008, at 11:46 PM, Maciej Stachowiak wrote:
>> Personally I think use of the local-scope eval should be discouraged. We should introduce an explicit globalEval function which has eval function rather than eval operator semantics, i.e. evaluates at global scope. In my experience, programs using eval rarely truly want local eval,
> SunSpider has some evals that absolutely want their caller's scope.
>> and so they are doing something that defeats lexecial analysis for no reason.
> There are lots of dumb eval uses, but I do not agree that most eval calls could be global-eval. The EXT Ajax library among many others uses local eval to compile optimized selector-matching functions, e.g. IIRC gmail uses local eval (and global).
We use global eval for dynamic loading of code.
We also use eval in a few places to turn responses loaded from the
server as text into object structures. These should all be
replaceable with JSON.parse.
I often find myself wanting an eval without side effects (except for
the return value of course). Having this would allow the js engines to
not have to go into slow mode when they see an eval.
>> I think we should even consider banning local eval from strict mode.
> In light of the examples I gave above, and more that are pretty easy to find, I think this would make strict mode unused in practice.
> Es3.x-discuss mailing list
> Es3.x-discuss at mozilla.org
More information about the Es-discuss