Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22084

Re: What's wrong with arguments.callee ?

Message-ID <14451970.gaMzNCkPz3@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-11-20 22:27 +0100
Subject Re: What's wrong with arguments.callee ?
Newsgroups comp.lang.javascript
References <708973f8-8cc4-409f-b763-f1ef0d455b58@l43g2000hsh.googlegroups.com> <c95a09a4-4230-4ec1-a65c-648422284e94@googlegroups.com>

Show all headers | View raw


Archenoth wrote:

> On Sunday, September 14, 2008 3:18:03 AM UTC-6, Jorge wrote:
             ^^^^^^^^^^^^^^^^^^
Good morning.

>> Why is it listed here :
>> 
>> http://www.crockford.com/javascript/recommend.html
>> 
>> under "deprecation" ?
>> 
>> Without it, how is an anonymous function() going to call itself
>> (recursively) ?
>> 
>> I use to write timers like this :
>> 
>> setTimeout( function () {
>>   (...)
>>   setTimeout( arguments.callee, ms );
>> }, ms );
>> 
>> How am I suppossed to do that without arguments.callee ?
>> 
>> Thanks,
>> --
>> Jorge.
> 
> You can have an inline named function like so:
> 
>> setTimeout( function loop() {
>>   (...)
>>   setTimeout( loop, ms );
>> }, ms );
> 
> Early versions of the language never allowed for named functions as
> expressions, which made anonymous recursion impossible. So, to allow for
> this sort of recursion, arguments.callee was born as a bit of a quick-fix.

Wishful thinking.

If “the language” is supposed to be Netscape JavaScript (not the only 
ECMAScript implementation that is on-topic here), then know that 
arguments.callee was introduced with JavaScript 1.2 in Netscape Navigator 
4.0 –

<http://faqintosh.com/risorse/web/netscape/CoreReferenceJS14/function.htm>

– and so were function expressions, *both* anonymous and named (AFAIK the 
proof is in the pudding only; should it be possible to make the ECMAScript 
Support Matrix 2 that much backwards-compatible, those test results will be 
contained in there).

> But now that that has been remedied,

arguments.callee still works, but not in strict mode.  It is *that* design 
decision that is being discussed in this thread.

> there is little reason to use it. (Aside from taking up a name in the
> namespace within the current scope.)
> 
> I had many uses for arguments.callee too, but upon further investigation,
> it seems as though inline named functions solve all of the problems I had
> before, and allow for some other nifty little constructs.

Please read the whole thread before replying late (especially when it is 
*that* old).  TIA.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: What's wrong with arguments.callee ? Archenoth <gir7590@gmail.com> - 2013-11-20 11:02 -0800
  Re: What's wrong with arguments.callee ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-20 22:27 +0100

csiph-web