Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does my Loop end after 11 Loops?
#70
The simplest iteration doesn't need any loop construct. In the least it requires a counting variable that could be tested with "IF" and then just use "GOTO" to go back to the beginning of the loop. The same cannot be said about recursion, not only is any variable needed to test but the other undesireable performance and memory-use overhead.

QB64(PE) is clever enough to somehow translate "WHILE... WEND" or "DO... LOOP" into C++ code so that it doesn't even require any more memory consumption than at least one variable that has to trigger a condition, either to keep the loop going or to stop it, up to the programmer to decide. Then there are other tools like "EXIT DO" and "_CONTINUE. Recursion doesn't offer any of that stuff and is the same hog in any programming language including LISP. Without recursion, some routines would become complicated such as the famous Quicksort. Otherwise it must be used where it's absolutely necessary.
Reply


Messages In This Thread
Why does my Loop end after 11 Loops? - by Dimster - 02-06-2023, 07:08 PM
RE: Why does my Loop end after 11 Loops? - by mnrvovrfc - 02-13-2023, 10:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Exiting sub while inside a loop PhilOfPerth 5 525 12-05-2025, 09:40 AM
Last Post: PhilOfPerth
  Do Loop, Sleep and Mouse Button Dimster 5 599 09-06-2025, 12:57 PM
Last Post: Dimster
  Using modulo to loop through lists fistfullofnails 3 725 09-03-2025, 11:50 PM
Last Post: fistfullofnails
  What is wrong with this for/next loop Helium5793 6 1,155 04-15-2025, 05:11 PM
Last Post: Kernelpanic
  Question on ln in a for/next loop Dimster 13 2,251 09-13-2024, 11:07 PM
Last Post: Kernelpanic

Forum Jump:


Users browsing this thread: 1 Guest(s)