Ye olde arguments argument (was: Topic list - pending changes and issues for the ES3.1 spec)
erik.arvidsson at gmail.com
Fri Sep 12 21:05:53 PDT 2008
Inside Google we have a few occurrences of arguments.callee. Some of
these are from Prototype, MochiKit, jQuery and other third party code.
I agree with Tobie regarding the 2 use cases but there is one more
related use case and that is arguments.callee.caller and I know a lot
of developers here rely on and that to be able to generate a stack
trace. This is crucial for fixing bugs in production systems.
SpiderMonkey has the Error.prototype.stack property and if that was
supported everywhere I don't think there would be any serious
complaints about removing arguments.callee and
On Sat, Sep 13, 2008 at 08:19, Bob Ippolito <bob at redivi.com> wrote:
> I found it convenient when writing MochiKit for the same reasons that
> it's in Prototype but it would be rather simple to change things
> around to use named references to functions or whatever else was
> appropriate. It occurs 28 times in trunk.
> On Fri, Sep 12, 2008 at 5:08 PM, Brendan Eich <brendan at mozilla.org> wrote:
>> Great -- good to have library authors / maintainers on this list.
>> I hold no brief for callee. The only issue in its favor is the cost of
>> migrating to strict mode. A new version of Prototype that loses
>> internal arguments.callee uses and is otherwise compatible helps.
>> Dojo and other Ajax folks on the list, please pipe up.
>> / be
>> Sent from my iPhone
>> On Sep 12, 2008, at 6:54 PM, Tobie Langel <tobie.langel at gmail.com>
>>> On Sep 11, 2008, at 14:34 , Brendan Eich wrote:
>>>> I snipped your words about callee, but it's used quite a bit in Ajax
>>>> libraries, e.g, Prototype:
>>>> $ grep -w callee prottype.js
>>>> replacement = arguments.callee.prepareReplacement(replacement);
>>>> var self = arguments.callee;
>>>> parts.add = arguments.callee.addPair;
>>>> (Prototype 184.108.40.206.)
>>> In Prototype, arguments.callee is used in two distinct cases:
>>> 1) reading a property of the callee, and
>>> 2) recursively calling the callee.
>>> Case #1 is easily solved by storing the said property in a closure,
>>> or by setting it elsewhere (where it probably would be a better fit,
>>> Case #2 is easily solved by using a named function instead. For the
>>> particular case where it is used in Prototype, the anonymous
>>> function lies inside of a closure, so there is no chance of
>>> triggering the JScript scope bug nor of polluting the global
>>> namespace when naming it.
>>> From what I understand, ES 3.1 strict mode compliance will be opt-in
>>> and will require at least slight source code modifications (if only
>>> to prepend it with the 'use strict'; expression). So current
>>> versions of Prototype (or other libs, for that matter), will not be
>>> ES 3.1 'strict' compliant by default.
>>> I'm not really worried about modifying Prototype to avoid use of the
>>> arguments.callee property. As a matter of fact, we've already done
>>> so in a development branch for Caja compliance.
>>> Note that jQuery does not use arguments.callee at all.
>> Es-discuss mailing list
>> Es-discuss at mozilla.org
> Es-discuss mailing list
> Es-discuss at mozilla.org
More information about the Es-discuss