If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > recursion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-04, 06:06
twokai twokai is offline
Registered User
 
Join Date: Sep 2004
Posts: 8
Unhappy recursion

is it ok to use recursive function from with in a loop?
Reply With Quote
  #2 (permalink)  
Old 10-28-04, 10:54
Pat Phelan Pat Phelan is online now
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
What would constitute "Ok" in this case?

Will the compiler allow you to call a recursive function from within a loop? Certainly. The compiler doesn't have any clue that a function is recursive, and really doesn't care either.

Will the person doing the code review permit a call to a recursive function? They ought to, but that doesn't mean that they will.

-PatP
Reply With Quote
  #3 (permalink)  
Old 11-06-04, 10:46
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
Many algorithms are "naturally recursive" and are implemented by recursive calls that occur within a loop.

There is no, "absolute, right-or-wrong, 'OK or not OK'" to be found anywhere in computer programming ... unless you are a pundit selling books and seminars!

What matters most is that your code is clear. That it is easy to understand what your code is doing and why. That it is easy to verify that your recursive code won't "recurse forever." That your algorithm is efficient and appropriate.

And... well-documented! "Use comments, dammit!"
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On