3 ms·
Looping, as in using a loop keyword, is synchronous. Recursion is also a loop, but can iterate asynchronously as necessary. That is the primary advantage.
by austin-cheney 4y ago
Looping, as in using a loop keyword, is synchronous. Recursion is also a loop, but can iterate asynchronously as necessary. That is the primary advantage.
- KingMob 4y agoRecursion doesn't do that by default, though. And if you have to alter your code to run recursive fns on a new thread or executor, nothing prevents you from doing something similar with a loop, either.
- austin-cheney 4y agoRecursion does do that by default respective to what the given function executes. No alteration or special convention is required. Loops that require use of syntax other than a function call are synchronous only. If it would you can find me on IRC and I would be more than happy to show you how to program.
- KingMob 4y agoI see you've gone from recursion "can iterate asynchronously" to it "does do that by default". In most languages, recursion is not asynchronous, even if it could be, which is part of the point I was making. I'm guessing English is not your first language.