02-13-2023, 10:18 PM
(This post was last modified: 02-13-2023, 10:19 PM by mnrvovrfc.
Edit Reason: dump typos from week-long headache LOL
)
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.
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.