Thanks James.

If any one else is as new to functional stuff as me then I found this
in Paul Graham's book which enables me to reason logically about the
matter (hopefully)

"A good compiler can compile a tail call into a goto, and so can
compile a tail recursive function into a loop. In typical machine
language code, when control arrives for the first time at the segment
of instructions representing len (a local fn) there is information on
the stack saying what to do upon returning. Because nothing remains to
be done after the recursive call, this information remains valid for
the second call as well"

On Jun 15, 11:28 pm, James Reeves <jree...@weavejester.com> wrote:
> On 15 June 2010 22:56, Quzanti <quza...@googlemail.com> wrote:
>
> > Thanks Mike.
>
> > So does is the only kind of recursion optimisation tail recursion?
>
> > Can you only eliminate stack calls in tail calls?
>
> No, you can also eliminate stack calls using lazy-seq or trampolines.
>
> If you provide some example code of what you are currently doing, it
> would be easier to gauge what is the most suitable approach.
>
> You might not even need to bother eliminating stack calls, if you know
> you're never going to recurse very far.
>
> > Having some sort of hint about this in the recur documentation might
> > be helpful?
>
> Well, the docs do say "recur in other than a tail position is an
> error", though that does assume the reader knows what the tail
> position of a function is.
>
> - James

-- 
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

Reply via email to