|
![](/i/fill.gif) |
Invisible <voi### [at] dev null> wrote:
> The idea here is that we jump to one label, then jump to another, then
> jump to another, never returning to the "caller".
>
> If we implement this using C functions that never return, an unbounded
> amount of stack gets eaten.
>
> Hence, they arranged for each function to *return* the function it would
> like to jump to next, rather than actually jumping to it, and the loop I
> posted is apparently the magic incantation that implements the jumping.
Yes, indeed.
http://en.wikipedia.org/wiki/Tail_recursion#Implementation_methods
I take it that you were looking at the C output of GHC, right? Haskell relies
on tail-recursion as much as any other functional language, as Scheme. The
method it is implemented underneath is as a trampoline.
Post a reply to this message
|
![](/i/fill.gif) |