Maybe this point about Racket is too off-topic for the list, but: On Aug 10, 2010, at 4:55 AM, Mark Engelberg wrote:
> Generally speaking, I find I do not have to worry about "blowing the > stack" in Scheme, and as a result, non-tail-call structural recursion > (such as the algorithm that kicked off this thread) is perfectly > idiomatic in the implementations of Scheme I have used (mostly > Racket). In Clojure, I find stack limitations are a real issue unless > I transform the algorithms into a tail-recursive accumulator style. > For lists, it's usually not hard. For trees, it can be a bit of a > pain. You don't worry about blowing the stack in Racket with recursion because they implement stack copying particularly elegantly: when you are about to blow the stack, the stack is copied to the heap and then blown away. A "handler" procedure is called (i.e. placed on the top of the stack), and then your computation proceeds. When you return your way back to the handler, it recalls the previous stack from the heap, jumps to the bottom of it, and your computation proceeds. In effect, the stack is treated as a limited-size window into the heap, so you will never run out of stack until you run out of heap. It's a neat trick, and could (in principle) be done on the JVM, but probably involves a significant speed trade-off even for code that doesn't take advantage of it. (The only way I can think of doing it is to follow the process outlined in "Continuations from Generalized Stack Inspection" by the PLT Folks, which requires installing an exception handler around each procedure to catch stack-overflow exceptions and "re-build" the current continuation on the heap.) I suspect that Chicken, with its "the Stack is the first generation of a copying generational garbage collector" would also have this "unlimited stack" property, but I don't know about the other Schemes---it's certainly standards complying to blow up when you run out of stack. Sorry for the digression; I hope people find it interesting. Will -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en