Scriptorium
Thursday, August 07, 2003
  Continuations in R5RS
I read about continuations in the R5RS the other day, and it made a lot of sense. I will attempt to describe my understanding of it now.

Call-with-current-continuation (call/cc) takes one argument, which should be a procedure, lets call it "proc-a", which itself takes one argument. Remember that in Scheme, procedures are objects that can be assigned to variables and passed as arguments. Call/cc then calls proc-a, passing it an argument which is called "the continuation". Proc-a can now do whatever it wants with the continuation, storing it in a variable, passing it to other procedures, or whatever. At any later point, the continuation itself can be called as a procedure, which results in the call state of the program rolling back to what it was at the invocation of the call/cc. It is similar to setjmp/longjmp in C, but my understanding is that it is much more powerful. I'm sure that understanding and appreciating the implications of that power will take me a while.
 
Greg Graham's writings on software and theology.

My Photo
Name: Gregory Graham
Location: Irving, Texas, United States

Theology student and Technology Director

Archives
July 2003 / August 2003 / November 2004 / December 2004 / January 2005 / February 2005 / March 2005 / April 2005 / May 2005 / October 2005 / November 2005 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / March 2009 / July 2009 / August 2009 / October 2009 /


Powered by Blogger

Subscribe to
Posts [Atom]