4 ms·
Another difference not mentioned is given the use of recursion in Haskell and the JVM's lack of tail-call optimisation, I have to wonder how dangerous this is.
by cgh 13y ago
Another difference not mentioned is given the use of recursion in Haskell and the JVM's lack of tail-call optimisation, I have to wonder how dangerous this is. I know Clojure has recur (I'm not a Clojure programmer) but unless Frege has something similar, I predict many an exploding stack.
- cgag 13y agohttp://stackoverflow.com/questions/10008673/does-frege-perform-tail-call-optimization http://stackoverflow.com/questions/10008673/does-frege-perfo...
- dustingetz 13y agoIt can compile to a loop. JVM can't optimize it for free at runtime. Scala has tail recursion elimination
- anonymoushn 13y agoPlease, scalac performs TCO in fewer cases than g++. Some JVMs are able to perform TCO, which is nice since scalac won't do it.
- bunderbunder 13y agoWhat about tail calls for mutually recursive functions? My understanding is that Scala is not able to do tail call elimination in this situation. So the only situation where you can be sure that deep recursion won't overflow the stack is when a function is tail calling itself. If Frege isn't able to do any better with mutual recursion then that might be a severe limitation on its utility. Scala users can work around the issue by writing loops manually. In a pure language, not so much.