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

Brendan Eich brendan at
Mon Nov 3 11:32:55 PST 2008

On Nov 2, 2008, at 3:22 PM, Tobie Langel wrote:

> 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.

Good to hear this confirmed -- it was not clear from the Mozilla CVS  
and bugzilla histories.

>> 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.



More information about the Es-discuss mailing list