3 ms·
> there's a special macro called loop to make tail recursive calls. This uses a keyword recur to call back into the loop. This isn't so much a language designe
by madhadron 6y ago
> there's a special macro called loop to make tail recursive calls. This uses a keyword recur to call back into the loop.
This isn't so much a language designer choice as a consequence of targeting the JVM. Tail recursion on the JVM has been a problem for decades.
- hencq 6y agoThat's not true. The JVM doesn't optimize tail calls, so, yes, that is a limitation. However, tail recursion (a subset of tail calls) is easy to detect and can be turned into iteration. That's exactly what loop/recur does. That syntax is a choice though. They could have decided to have named lets and make calls in tail position do the same thing as loop/recur does now. Instead they decided to make the syntax more explicit, so the tail recursion is more obvious.