Function constructor create named function expression?

Brendan Eich brendan at mozilla.com
Wed Jun 30 09:48:02 PDT 2010


On Jun 30, 2010, at 9:41 AM, Brendan Eich wrote:

> Previously: https://mail.mozilla.org/pipermail/es-discuss/2009-March/008954.html

Sorry, a bit terse there. Please do search the mailman archive (I use Google site search: site:mail.mozilla.org Function.create -- but that lets me down sometimes), and (what's more likely to bear fruit) the wiki:

http://wiki.ecmascript.org/doku.php?id=strawman:name_property_of_functions

/be

> 
> /be
> 
> On Jun 30, 2010, at 2:38 AM, Asen Bozhilov wrote:
> 
>> Function constructor is considered as bad practice by many JS gurus,
>> but sometimes I use Function constructor for shorter scope chain. The
>> problem in ES5 strict mode come when I want recursive call of
>> function, which is created by Function constructor. I can not use
>> `arguments.callee` and Function constructor does not provide way to
>> create NFE. I would like to see Function constructor, which can
>> create:
>> 
>> - NamedFunctionExpression
>> - Setter for [[Scope]] internal property
>> 
>> For example:
>> 
>> var F = Function({
>>   name : 'NFE',
>>   arguments : ['arg1', 'arg2', 'argN'],
>>   scope : {a : 10, b : 20},
>>   body  : "print(typeof NFE); print(a + b);"
>> });
>> 
>> F.length;
>> -> 3
>> 
>> F();
>> -> function
>> -> 30
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list