Hacker News new | ask | show | jobs
by justinethier 3610 days ago
Here is a basic introduction to the stack and heap, with examples in C: http://gribblelab.org/CBootcamp/7_Memory_Stack_vs_Heap.html

This might help with continuations: https://en.wikipedia.org/wiki/Continuation

Here is a really simple example of simulating a C return using call/cc:

  (display
    (call/cc
      (lambda (return)
        (display "hello ")
        (return "world")
        (display "never reached"))))
2 comments

For continuations, I would actually recomend "LAMBDA: The Ultimate Imperative" (http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-...). It's not exactly light reading, but it gives the best explanation of continuations that I've seen.

If you just want the simple explanation: A continuation is a copy of the return stack at the instant it was captured. When a continuation is invoked, that copy replaces the stack.

This is perfect! Thank you!
Thanks!