Can one not detect that a recursive call is a tail call and then transform
the AST so that its iterative instead - ie, not use the stack besides for
initial setup of local variables (which then get reused in each recursive
tail-call). Isn't this how its done in native compiled languages with TCO?
How is this different from generating bytecode for iterative loops in
imperative languages, or from what recur does? Alternatively, why can't the
tail call be detected and converted into recur? I'm guessing that the
problem is detecting tal calls - but why; speed of dynamic compilation?
Something else?

Obviously I'm missing something fundamental here - can somebody explain to
me what it is?

Thanks!

On 3 August 2010 05:54, Wilson MacGyver <wmacgy...@gmail.com> wrote:

> as Rich Hickey stated
>
> question: Is it fundamentally impossible to do TCO on JVM due to
> current JVM lack of primitives to do so? Would TCO ever be possible on
> the JVM without a new JVM design?
> rhickey: TCO is easy if you are an interpreter - see SISC Scheme.
> Using Java's call stack, the JVM would have to provide it. There are
> no fundamental technical difficulties, but potential issues for the
> security model, which uses the call stack to ensure privileges.
>
> On Mon, Aug 2, 2010 at 10:16 PM, Dan Kersten <dkers...@gmail.com> wrote:
> > Why can't the clojure bytecode compiler hand-perform this like
> > functional languages do when compiling to native code? Is it to keep
> > the clojure compiler fast (for dynamic runtime compilation), since
> > performing tail call optimisation presumably requires a bunch of extra
> > checks and more complex code generation? Perhaps this could be done on
> > AOT compilation?
> >
> > On Aug 3, 2:58 am, Frederick Polgardy <f...@polgardy.com> wrote:
> >> It means that the JVM doesn't look at method calls and figure out that
> they're in tail call position and optimize them. You can hand-write code
> that performs a goto in a tight loop (like recur does), but means you can't
> assume that method calls in general will be tail call optimized.
> >>
> >> -Fred
> >>
> >> --
> >> Science answers questions; philosophy questions answers.
> >>
> >> On Aug 2, 2010, at 4:09 PM, Dale wrote:
> >>
> >> > The JVM has an unconditional goto opcode and the ability to re-bind
> >> > function parameters, so why no tail-call optimization? Thanks.
> >>
> >> > Dale
> >>
> >> > --
> >> > 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<clojure%2bunsubscr...@googlegroups.com>
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/clojure?hl=en
> >
> > --
> > 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<clojure%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
>
>
> --
> Omnem crede diem tibi diluxisse supremum.
>
> --
> 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<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Daniel Kersten.
Leveraging dynamic paradigms since the synergies of 1985.

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