arguments.callee in Harmony

Oliver Hunt oliver at apple.com
Thu Sep 24 15:59:16 PDT 2009


On Sep 24, 2009, at 3:55 PM, Charles Jolley wrote:

>> Given your example, a named function expression would do the job  
>> trivially:
>>
>> ClassB = ClassA.extend({
>>
>>   foo: function foo() {
>>     foo.base.apply(this, arguments); // calls super!
>>     // other code
>>   }
>>
>> });
>
> This works but, as I said, this approach has a couple of drawbacks:
>
> 1. The function has to be named twice (foo: function foo()).  This  
> makes the code harder to read (especially with long names) and its  
> not very developer-friendly since its pointless cruft.
>
> 2. This is also fragile.  If you forget the second name, the code  
> would still parse but it will be seriously broken.  Additionally, if  
> you decided to rename the function you would also have to edit the  
> code on the inside.  Hurts the "copy and paste" aspect of it.
>
> In general I think this particular approach is not developer  
> friendly enough.
The function expression name is fairly irrelevant, so you could have a  
standard style guideline
foo : function callee() {
     callee.base.apply ...
}

--Oliver


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090924/5cb0308f/attachment-0001.html>


More information about the es-discuss mailing list