POV-Ray : Newsgroups : povray.off-topic : Random C craziness : Re: Random C craziness Server Time
7 Sep 2024 11:26:41 EDT (-0400)
  Re: Random C craziness  
From: nemesis
Date: 26 Jul 2008 17:30:00
Message: <web.488b96f97f33a1c3de7267810@news.povray.org>
Invisible <voi### [at] devnull> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.