2 ms·
The 'recur' operator was meant as a replacement for the lack of tail-recursive optimization in the JVM, and is often seen as a recursion operator, not an iterat
by lmkg 16y ago
The 'recur' operator was meant as a replacement for the lack of tail-recursive optimization in the JVM, and is often seen as a recursion operator, not an iteration operator, especially by people coming from a functional background. People from an imperative background seem to understand it as a type of limited GOTO, with only a single place it can go to; people from a functional background see it as similar to calling the function you're in by name, but mentioning the recursion explicitly for compiler optimizations.
Recur seems to be maligned by people on both sides of the recursion/iteration divide. I rather like it, in no small part because I think the divide is silly. Iteration is the same as recursion, both semantically (especially if you have tail-call optimization) and syntactically (especially if you can have multiple loop variables). Recur blurs the distinction. If you think the distinction is important, it's confounding; if you think the distinction is silly, it's unifying.