Ye olde arguments argument (was: Topic list - pending changes and issues for the ES3.1 spec)

Bob Ippolito bob at redivi.com
Fri Sep 12 17:19:25 PDT 2008


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.

-bob

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>
> wrote:
>
>>
>> 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 1.5.1.1.)
>>
>> 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,
>> anyway).
>>
>> 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.
>>
>> Best,
>>
>> Tobie
>>
>>
>>
>>
>>
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the Es-discuss mailing list