In what ways does the following "eval" regularity break?

Tobie Langel tobie.langel at gmail.com
Sun Nov 2 15:22:41 PST 2008


On Oct 30, 2008, at 22:28 , Brendan Eich wrote:
> As far as I can tell (Prototype folks on this list, please help  
> here), this is all synthetic test-fodder. The test scripts do not  
> want a local var binding.

I'm not sure what you mean by synthetic test-fodder in that case. The  
function which Maciej mentions is mainly used to evaluate the content  
of script tags contained in an HTML snippet returned by an ajax  
request. Although it's rare to need to define variables in that  
context, the behaviour expected by users when they do so is for those  
variables to live in the global scope.

> On the other hand, anyone evaluating
>
>   (function xxx(){ ["var x"].forEach(eval); })();
>
> would get a global var x, which should be the specified outcome,  
> but which is probably a mistake on the programmer's part outside of  
> test code.

Agreed.

Best,

Tobie


More information about the Es-discuss mailing list