On Mar 10, 2009, at 9:02 AM, Mark S. Miller wrote:

On Tue, Mar 10, 2009 at 8:52 AM, Allen Wirfs-Brock <allen.wirfs-br...@microsoft.com> wrote:

In reviewing the spec. I was reminded that arguments.callee is disabled within strict mode functions.  Do you recall why you wanted to do this, other than general dislike of arguments.

POLA. A frequent and sensible pattern of use for "arguments" is to pass it along to someone else to give them access to your arguments list. In typical usage, it is not usually intended or desired to thereby give them access to the function itself, not to give them the ability to alter your parameter variables (hence the lack of joining).

The point about joining is good, but not relevant to callee. If f calls g(arguments) and g takes formal parameter a, g cannot abuse a.callee to alias f's active variables.

Before giving callee the boot, has anyone interacted with Ajax library authors? Here (excluding lines longer than 256) are uses of callee in Dojo, Ext, JQuery, MochiKit, and Prototype:

Attachment: C2
Description: Binary data



It occurs to me, that using arguments.callee is the only way  to express recursion within a function created using the Function constructor and that use of the Function constructor (rather than eval) should probably be encouraged for dynamically constructing functions from source code.


Why? I was thinking exactly the opposite: That we should encourage use of eval() rather than the Function constructor for dynamic creation of functions.

Whatever encouragement the committee gives, with words or strict mode sticks, is not likely to have much effect on the bulk of Web code. Strict mode sticks may have an effect over time, but carrots work better.

The Function constructor is used far less than eval("function f() {...}") or eval("var f = function(){...}") or even (this works only in some implementations and is not legal syntax in ES3) eval("function (){...}"). When all you have is the eval hammer, everything looks like your thumb.

Also, the Function constructor does not provide for a name (wherefore Maciej's Function.create). And it scopes the created function to the global object. There are reasonable use-cases for generated functions in local scopes.

/be




--
   Cheers,
   --MarkM
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to