I think what you're talking about is continuation passing style -
http://en.wikipedia.org/wiki/Continuation-passing_style

I think there was a thread on it a few months back, but from what I
remember its not supported (its dependent on TCO to prevent the stack
from exploding as explained above).

On Jan 26, 4:48 pm, Armando Blancas <armando_blan...@yahoo.com> wrote:
> These last posts cleared it up. Thanks.
>
> Which remind me, I think one of the SICP lectures on youtube mentions
> tail calls to *other* functions, which I totally forgot, with an
> example of a person doing something for another doing something for
> another... and the last one just gives the result to the first. That
> ain't no internal loop.
>
> On Jan 26, 1:23 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 2011/1/26 Alan <a...@malloys.org>:
>
> > > Now try writing two mutually-recursive functions. In Scheme (as I
> > > understand it) that will get optimized into a jump from one function
> > > to the other, while in Clojure it will use the stack.
>
> > And that's why Rich introduced clojure.core/trampoline.
>
> > Cheers,
>
> > --
> > Laurent
>
> > > On Jan 26, 1:10 pm, Armando Blancas <armando_blan...@yahoo.com> wrote:
> > >> From SICP: "With a tail-recursive implementation, iteration can be
> > >> expressed using the ordinary procedure call mechanism". As I
> > >> understand this, a tail call is a loop with functional notation but
> > >> not actually a function call. That's why I find this issue difficult
> > >> to follow, since loops are internal details of a function/method and
> > >> don't get involved with calls, stack frames, access security, or how
> > >> the jit-compiled code may or may not be optimized. So there's
> > >> something key here that I'm missing.
>
> > >> In a little project of mine I plan on doing this (hand-coded with ASM
> > >> as my compiler doesn't do TCO yet). That seems to work but I wonder
> > >> what issues may come up.
>
> > >> int fact(int n, int r) {
> > >>   if (n == 0) return r;
> > >>   else return fact(n-1, n*r);}
>
> > >>    0:   iload_0
> > >>    1:   ifne    6
> > >>    4:   iload_1
> > >>    5:   ireturn
> > >>    6:   iload_0
> > >>    7:   istore_2 // temp for n
> > >>    8:   iload_2
> > >>    9:   iconst_1
> > >>    10:  isub
> > >>    11:  istore_0
> > >>    12:  iload_2
> > >>    13:  iload_1
> > >>    14:  imul
> > >>    15:  istore_1
> > >>    16:  goto    0
>
> > >> On Jan 26, 11:20 am, Luc Prefontaine <lprefonta...@softaddicts.ca>
> > >> wrote:
>
> > >> > From what I recall from a previous thread it would require so much 
> > >> > byte code tweaking that
> > >> > Hot Spot optimizations would become useless.
>
> > >> > You can search the mailing list, you will find a couple of instructive 
> > >> > discussions
> > >> > about this.
>
> > >> > Luc P.
>
> > >> > On Wed, 26 Jan 2011 10:01:04 -0800
>
> > >> > Raoul Duke <rao...@gmail.com> wrote:
> > >> > > On Wed, Jan 26, 2011 at 7:41 AM, Michael Gardner
> > >> > > <gardne...@gmail.com> wrote:
> > >> > > > However, the JVM does not support tail-call optimization.
> > >> > > > Apparently Clojure can't support implicit TCO without support from
> > >> > > > the JVM
>
> > >> > > always wondered about that also wrt scala etc., am under the
> > >> > > impression that it is implementable, but it would be too slow?
>
> > >> > --
> > >> > Luc P.
>
> > >> > ================
> > >> > The rabid Muppet
>
> > > --
> > > 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-Hide quoted text -
>
> > - Show quoted text -

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