Hacker News new | ask | show | jobs
by zelphirkalt 2007 days ago
Is trampolining automatic, or does it have its own syntax as well?

Even a little thing like (recur ...) could be a tiny amount of friction. But good to read, that the usual cases are apparently handled well in the language.

1 comments

The builtin helper function is called trampoline, it's a higher order function that relies on the mutually recursive functions returning "trampolines" or closures that do the desired subsequent call.

The trampoline pattern is an old trick that can also be imlemented in other languages to avoid stack consumption in mutually recursive calls.

I know what trampolining does, thank you.

That's unfortunate, that it is an additional function call, which needs to be explicitly written out. I'd guess such is necessary ultimately, because of limitations of the JVM and its limitations regarding recursion.