Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

jslint_com · This group has moved to Google Plus.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 584
  • Category: JavaScript
  • Founded: Mar 7, 2008
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Mutual Recursion   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages Sort by Date  
#399 From: "Douglas Crockford" <douglas@...>
Date: Tue Mar 10, 2009 8:09 pm
Subject: Mutual Recursion
douglascrock...
Send Email Send Email
 
A robust coding style demands that symbols should be declared before they are
used. But how is this possible in the case of mutually recursive functions? If
function a calls function b, and if function b calls function a, how can a and b
both be declared before they are used?

JavaScript provides two ways.

var a = function () {
var b = function () {
... a() ...
};
... b() ...
};


var a;
var b = function () {
... a() ...
};
a = function () {
... b() ...
};




#400 From: Alexandre Morgaut <morgaut@...>
Date: Wed Mar 11, 2009 1:17 pm
Subject: RE: [jslint] Mutual Recursion
morgaut_a
Send Email Send Email
 


With the difference that in the first way the function b is declared in the
scope of function a
Whereas in the second way function a and b are in the same scope
(with indentation it would have clearer)

To: jslint_com@yahoogroups.com
From: douglas@...
Date: Tue, 10 Mar 2009 20:09:38 +0000
Subject: [jslint] Mutual Recursion





















A robust coding style demands that symbols should be declared before
they are used. But how is this possible in the case of mutually recursive
functions? If function a calls function b, and if function b calls function a,
how can a and b both be declared before they are used?



JavaScript provides two ways.



var a = function () {

var b = function () {

... a() ...

};

... b() ...

};



var a;

var b = function () {

... a() ...

};

a = function () {

... b() ...

};






















_________________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  ! 
Téléchargez-le maintenant ! 
http://www.windowslive.fr/messenger/1.asp

[Non-text portions of this message have been removed]




#401 From: "Jakob Kruse" <kruse@...>
Date: Wed Mar 11, 2009 1:29 pm
Subject: RE: [jslint] Mutual Recursion
thekrucible
Send Email Send Email
 
The way I read this, in the first example the function ‘b’ is recreated (which
would take time) every time ‘a’ is called. Strictly speaking you would never
call the same ‘b’ function twice, but a new one each time. Or is that incorrect?

For that reason alone I would never use the first example.

/Jakob


From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On Behalf
Of Alexandre Morgaut
Sent: 11. marts 2009 14:17
To: jslint_com@yahoogroups.com
Subject: RE: [jslint] Mutual Recursion



With the difference that in the first way the function b is declared in the
scope of function a
Whereas in the second way function a and b are in the same scope
(with indentation it would have clearer)

To: jslint_com@yahoogroups.com
From: douglas@...
Date: Tue, 10 Mar 2009 20:09:38 +0000
Subject: [jslint] Mutual Recursion

A robust coding style demands that symbols should be declared before they are
used. But how is this possible in the case of mutually recursive functions? If
function a calls function b, and if function b calls function a, how can a and b
both be declared before they are used?

JavaScript provides two ways.

var a = function () {

var b = function () {

... a() ...

};

... b() ...

};

var a;

var b = function () {

... a() ...

};

a = function () {

... b() ...

};










__________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger !
Téléchargez-le maintenant !
http://www.windowslive.fr/messenger/1.asp

[Non-text portions of this message have been removed]


[Non-text portions of this message have been removed]




#402 From: Alexandre Morgaut <morgaut@...>
Date: Wed Mar 11, 2009 2:00 pm
Subject: RE: [jslint] Mutual Recursion
morgaut_a
Send Email Send Email
 


I agree with you Jakob
For myself I may have declared the function with an empty function


var a = function() {};

So that :
- a validator which would check then var type wouldn't be surprised
- the developer knows what a is supposed to be (even if it should be evident
from a good naming convention and good comments)

To: jslint_com@yahoogroups.com
From: kruse@...
Date: Wed, 11 Mar 2009 14:29:44 +0100
Subject: RE: [jslint] Mutual Recursion





















The way I read this, in the first example the function ‘b’ is
recreated (which would take time) every time ‘a’ is called. Strictly speaking
you would never call the same ‘b’ function twice, but a new one each time. Or is
that incorrect?



For that reason alone I would never use the first example.



/Jakob





From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On Behalf
Of Alexandre Morgaut

Sent: 11. marts 2009 14:17

To: jslint_com@yahoogroups.com

Subject: RE: [jslint] Mutual Recursion





With the difference that in the first way the function b is declared in the
scope of function a

Whereas in the second way function a and b are in the same scope

(with indentation it would have clearer)



To: jslint_com@yahoogroups.com

From: douglas@...

Date: Tue, 10 Mar 2009 20:09:38 +0000

Subject: [jslint] Mutual Recursion



A robust coding style demands that symbols should be declared before they are
used. But how is this possible in the case of mutually recursive functions? If
function a calls function b, and if function b calls function a, how can a and b
both be declared before they are used?



JavaScript provides two ways.



var a = function () {



var b = function () {



... a() ...



};



... b() ...



};



var a;



var b = function () {



... a() ...



};



a = function () {



... b() ...



};



__________________________________________________________

Téléphonez gratuitement à tous vos proches avec Windows Live Messenger !
Téléchargez-le maintenant !

http://www.windowslive.fr/messenger/1.asp



[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]






















_________________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  ! 
Téléchargez-le maintenant !
http://www.windowslive.fr/messenger/1.asp

[Non-text portions of this message have been removed]




 
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help