From: Julian Fitzell Date: 2004-05-08T04:18:44+09:00 Subject: Re: What is Borges? Dick Davies wrote: > > I still can't get my head round continuations - does anyone have a good ref? > > All I've seen so far is either 'look, we can do goto' or > 'look, here's Borges', which is a learning curve so steep it starts to > look like a wall.... > I did a quick google search and came up with this mailing list thread: http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/msg00499.html It has the advantage of having a lot of people trying to explain it a lot of ways, so hopefully one of them will start to make sense to you. :) The explanation that has always worked for me is that a continuation remembers a point in the execution of your program. As long as you are holding onto that continuation you can, at any point (and as many times as you like), jump back to exactly that place in your program again. It's like a bookmark. You just replace your current execution context with the one you copied for the continuation and carry on executing. call/cc is a mechanism of getting/using the continuations which passed a continuation into the method (or block, depending on implementation) you ask it to call. The continuation it gives you is a capture of the point in the execution just before the call/cc method call returns. So by using that continuation, you can return from the method call over and over as many times as you like. We use this in seaside (and borges does the same) to allow the user to use the back button in the browser. No matter how many times the user goes back and clicks a link on the same page, the handling will always be done by the exact same execution context. It doesn't know it's being called over and over; it just knows it's supposed to handle the clicks generated from that page and it always does. Hope that helps, -- Julian Beta4 Productions http://www.beta4.com/