Hey Laurent, I had stack overflows because I had functions set up like this:
(defn parse-code [original-code formatted-code main-loop?] ... ) (defn format-list [original-code formatted-code] ... ) (defn format-string [original-code formatted-code] ... ) Now, whenever parse-code sees an opening parenthesis, it will call format-list. Easy enough. The tricky part is in the formatting functions. In format-list, we read characters until we get to a closing parenthesis. The logical step would be to return the formatted code back to parse-code, along with some information about how much of the original code was read. The problem with this approach is when you have structures nested within format-list. Let's say format-list reads a quote ("). How is format-list supposed to know that a quote begins a string? That's the job of parse-code. In that case, what I did was call parse-code again. This time, parse- code checks to see if a character is beginning another data structure. If it is, then it uses recursion *again* to process that data structure. This continues all the way until it finishes parsing and returns that back to the original format-list call, which now has to account for the data read by parse-code. If you followed that so far then you might see a problem. Instead of ever returning to parse-code, the functions are recur-ing between each other. Instead of the desired: parse-code format-list format-string ... The stack will look something like: parse-code format-list parse-code format-string parse-code format-list ... This is the domain of mutual recursion that drove me to find a different solution. ~ Kai On Jul 2, 2:37 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > > Ok, I'll wait then, thanks. > > BTW, I don't really understand how you could have StackOverflows. I > would expect that the solving algorithm would make the size of the > call stack proportional to the depth of the datastructure graph ? If > so, I guess that even the most evil human created code would not reach > the StackOverflow limit ? > > Regards, > > -- > Laurent > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---