Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22083 > unrolled thread
| Started by | Archenoth <gir7590@gmail.com> |
|---|---|
| First post | 2013-11-20 11:02 -0800 |
| Last post | 2013-11-20 22:27 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Archenoth <gir7590@gmail.com> |
|---|---|
| Date | 2013-11-20 11:02 -0800 |
| Subject | Re: What's wrong with arguments.callee ? |
| Message-ID | <c95a09a4-4230-4ec1-a65c-648422284e94@googlegroups.com> |
On Sunday, September 14, 2008 3:18:03 AM UTC-6, Jorge wrote:
> 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. But now that that has been remedied, 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.
[toc] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-20 22:27 +0100 |
| Message-ID | <14451970.gaMzNCkPz3@PointedEars.de> |
| In reply to | #22083 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web