News for hackers. Stuff that matters.
Re:Good design for Humans by Scarbutt on Tuesday May 29, 2018 @11:44AM (#17180169)
About that factorial code in Clojure, I wish in reality one could write beautiful recursive code like that without blowing the stack for large inputs, one of my main grips with Clojure.
Re:Good design for Humans by cr__ on Tuesday May 29, 2018 @02:30PM (#17181790)
Sure you can, you just have to make the recursive call explicit:

https://clojurebridge.github.io/community-docs/docs/clojure/...

This has the nice side effect of preventing you from writing a function that you think will be tail call optimized but really isn’t—the compiler will yell if your call to `recur` isn’t in tail position.

The code in the article doesn’t have the recursive call in tail position anyway, so it’s not like other languages would be able to optimize it away.