tail-call-optimization

Why does the JVM still not support tail-call optimization?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 03:47:05
Two years after does-the-jvm-prevent-tail-call-optimizations , there seems to be a prototype implementation and MLVM has listed the feature as "proto 80%" for some time now. Is there no active interest from Sun's/Oracle's side in supporting tail calls or is it just that tail calls are "[...] fated to come in second place on every feature priority list [...]" as mentioned at the JVM Language Summit ? I would be really interested if someone has tested a MLVM build and could share some impressions of how well it works (if at all). Update: Note that some VMs like Avian support proper tail-calls

Does Haskell have tail-recursive optimization?

寵の児 提交于 2019-11-26 03:18:07
问题 I discovered the \"time\" command in unix today and thought I\'d use it to check the difference in runtimes between tail-recursive and normal recursive functions in Haskell. I wrote the following functions: --tail recursive fac :: (Integral a) => a -> a fac x = fac\' x 1 where fac\' 1 y = y fac\' x y = fac\' (x-1) (x*y) --normal recursive facSlow :: (Integral a) => a -> a facSlow 1 = 1 facSlow x = x * facSlow (x-1) These are valid keeping in mind they were solely for use with this project, so

What Is Tail Call Optimization?

自古美人都是妖i 提交于 2019-11-26 01:18:30
问题 Very simply, what is tail-call optimization? More specifically, Can anyone show some small code snippets where it could be applied, and where not, with an explanation of why? 回答1: Tail-call optimization is where you are able to avoid allocating a new stack frame for a function because the calling function will simply return the value that it gets from the called function. The most common use is tail-recursion, where a recursive function written to take advantage of tail-call optimization can

Why does the JVM still not support tail-call optimization?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 01:14:21
问题 Two years after does-the-jvm-prevent-tail-call-optimizations, there seems to be a prototype implementation and MLVM has listed the feature as \"proto 80%\" for some time now. Is there no active interest from Sun\'s/Oracle\'s side in supporting tail calls or is it just that tail calls are \"[...] fated to come in second place on every feature priority list [...]\" as mentioned at the JVM Language Summit? I would be really interested if someone has tested a MLVM build and could share some

How do I replace while loops with a functional programming alternative without tail call optimization?

亡梦爱人 提交于 2019-11-25 23:49:15
问题 I am experimenting with a more functional style in my JavaScript; therefore, I have replaced for loops with utility functions such as map and reduce. However, I have not found a functional replacement for while loops since tail call optimization is generally not available for JavaScript. (From what I understand ES6 prevents tail calls from overflowing the stack but does not optimize their performance.) I explain what I have tried below, but the TLDR is: If I don\'t have tail call optimization