Note that *recursive* tail calls at least theoretically can be optimized using a jump -- basically turning the entire method into a loop. I'm not sure if any language does this currently (I'd be surprised if they didn't), but it's at least possible.
~~ Robert. Jon Harrop wrote: > On Thursday 02 April 2009 15:36:38 kirk wrote: >> Jon Harrop wrote: >>> On Thursday 02 April 2009 15:09:12 Charles Oliver Nutter wrote: >>>> It's not necessarily Sun's choice when it exhibits external behavioral >>>> changes. Such changes must be standardized so all JVMs will support >>>> them. If it were just up to Sun, it would probably go in (since I know I >>>> want it and several others want it). >>> Ok. I only care about Sun's JVM because it is the defacto standard. If >>> tail calls are not adopted as a standard across all JVMs, what are the >>> odds of Sun including them just in its own JVM as an extension? >> why do they have to be exposed? Isn't tail recursion and implementation >> detail? And an optimization at that? > > Elimination of tail calls is a requirement for certain kinds of program to > run > correctly. If tail calls are not eliminated, such programs leak stack space > until they die from a stack overflow exception. > > In particular, tail calls are important in functional programs because that > paradigm encourages the composition of functions into arbitrarily-long > pipelines that data flow through in order to produce the desired result. > Without tail calls, every stage in the pipeline leaks stack space. > > Note that "tail recursion" is a term typically used to describe the special > case of tail calls where the branch target is statically known and is often a > self-call. In general, tail calls refer to any calls in tail position and > they may well be calls to locations that are not statically known. Hence TCO > implementations often globally alter the calling convention used internally > by the VM and this can introduce disadvantages such as degraded performance > on other code. > -- ~~ Robert Fischer. Grails Training http://GroovyMag.com/training Smokejumper Consulting http://SmokejumperIT.com Enfranchised Mind Blog http://EnfranchisedMind.com/blog Check out my book, "Grails Persistence with GORM and GSQL"! http://www.smokejumperit.com/redirect.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to jvm-languages@googlegroups.com To unsubscribe from this group, send email to jvm-languages+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---