Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

To you lisp lovers

Name: Cudder !!RD3keS5C4KiAlK2 2013-06-29 0:06

What has lisp ever done for reducing the memory footprint of a computer program? The answer is nothing, nothing at all. This is all the work of C.

Name: Anonymous 2013-07-02 4:47

>>75
TCO in C/C++ has some challenges, while they aren't show stoppers. One complication is stack allocated memory. If you pass a pointer or reference to stack allocated memory when calling a function in a tail position, performing tail call optimization could crash the program, since using the pointer would then refer to stack used by the tail-called function.


int f()
{
  int x;
  return g(&x); // Not safe to tail call.
}


A C/C++ compiler needs to prove that TCO is safe first, which can become non-trivial or impossible, but is usually straight forward.

Most tail calls get compiled to simple jumps within a local body. The real deal tail calls that make debugging difficult and program control flow so difficult to follow are usually not much worse than a normal function call. There might be some shuffling on the stack. I guess my point is not to confuse functional style with the other features of lisp that make it more difficult to get high performance code, with that being garbage collection, dynamic typing, or the theme of interpretation.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List