[gambit-list] Help With Memory

Per Eckerdal per.eckerdal at gmail.com
Sat Sep 27 06:43:35 EDT 2008


> So can you give a non-trivial example?  As I said, I used it because my
> problem was the sort of thing that intro textbooks (e.g., The Scheme
> Programming Language) say to use it for.

I've been playing around with using continuations a little. It's a fun
little excercise and you can certainly use it to do some extraordinary
things. It really is a big gun. A good example of a less trivial thing
to do is continuation based web frameworks. Here are a couple of
articles that nicely explain the concept:

http://www.double.co.nz/scheme/modal-web-server.html

Other classic examples of what you can do is to implement coroutines,
Python-style generators, cooperative threads and exceptions. None of
those are impossible to understand, so I encourage you to look into
them if you're interested. I think continuations are a beautiful
concept, they are so simple and so powerful. However, it is not always
easy to get an overview of what's happening if you use them more than
just locally in a function. I find the interaction with the dynamic
environment especially difficult to grasp.

The relationship between call/cc and dynamic-wind is another
interesting example related to more complex use of call/cc. In the
appendix of http://mumble.net/~jar/pubs/scheme-of-things/june-92-meeting.ps
there is an implementation of dynamic-wind. I had a great "aha"
experience when I got how that code works, that code describes in a
very practical way how call/cc makes the stack into a tree.

hope that helps.

/Per



More information about the Gambit-list mailing list