On Fri, Apr 10, 2009 at 5:41 AM, Attila Szegedi <szege...@gmail.com> wrote:
> I'm replying more-or-less randomly to this message among all messages > debating whether TCO is a JVM implementation detail or not. Well, thanks for the implicit compliment. > My stance is that it is, in the same sense as GC is. I grant the force of your analogy between GC, which provides the illusion of an infinite heap in certain circumstances, and TCO, which provides the illusion of an infinite stack in certain circumstances. However, proper tail calling (PTC) is not the same concept as TCO. In a PTC language like Scheme, Haskell, or XSLT, tail calls serve the same function as iteration in a non-PTC language. In Scheme, for instance, the core language contains only constants, lexical variables, conditional evaluation, assignment, function calls, and lambda. A classical Scheme compiler reduces the full language (including two standard iteration constructs and any number of user-defined ones) to these few primitives, and then works hard to implement each of them with maximal efficiency. For a Scheme implementation not to be PTC is not like a JVM without GC, it's like a JVM that gratuitously pushes a new stack frame for every iteration of a while- or for-loop, and then carefully unwinds them (without using an exception) when the loop exits. That's not a trade-off, it's a pessimization. > (Mind you, due to the way it is compiled, this'll > prevent calls in a synchronized block to be optimized, as synchronized > blocks are always in a try although if the whole method has the > synchronized attribute, it should be fine). I don't see how. A synchronized method, like a synchronized block, has to exit the monitor, and the essence of a tail call is that there is nothing to do (as opposed to nothing visible to do) in the calling function after the called function returns. > Then again, can you imagine > really wanting to print a stack trace of a TCOd call chain containing > few millions of calls? Probably not. But there is also the stack-inspection-based security system. -- GMail doesn't have rotating .sigs, but you can see mine at http://www.ccil.org/~cowan/signatures --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---