3 ms·
I like this list. I don’t agree with every choice but so what: they are all thoughtful choices (except why do you need `recur`?) that reflect an opinionated po
by gumby 5y ago
I like this list. I don’t agree with every choice but so what: they are all thoughtful choices (except why do you need `recur`?) that reflect an opinionated position which I appreciate.
- kgwxd 5y agoI believe it was due to limitations of the JVM at the time. Edit: https://www.windley.com/archives/2008/11/tail_optimized_mutual_recursion_in_clojure.shtml https://www.windley.com/archives/2008/11/tail_optimized_mutu...
- erik_seaberg 5y agoI prefer Scala’s solution, where tail calls look like normal calls, and a @tailrec annotation can assert they really are optimized out (or break the build).
- gumby 5y agoSeems like they compiler could generate the trampoline itself and just ignore any recur that occurs.
- the-alchemist 5y agoThe upside of `recur` is that: * just by looking at the code you can tell if it's a tail call or not * easy to debug; no trampoline magic * guaranteed to work on any platform, whether it supports TCO or not * Javascript is a very popular target, via ClojureScript * who wants to test and remember if Chrome or Firefox or Safari implement TCO? or implement it properly? and which version(s) of those browsers implement TCO properly? * if you wanna want a trampoline, you got it! (https://clojuredocs.org/clojure.core/trampoline https://clojuredocs.org/clojure.core/trampoline)