Xref: utzoo comp.object:502 comp.lang.c++:5668 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!ctrsol!lll-winken!arisia!sgi!shinobu!odin!delrey!shap From: shap@delrey.sgi.com (Jonathan Shapiro) Newsgroups: comp.object,comp.lang.c++ Subject: Continuations Message-ID: <1623@odin.SGI.COM> Date: 27 Nov 89 16:34:59 GMT References: <2664@bingvaxu.cc.binghamton.edu> <9624@pyr.gatech.EDU> Sender: news@odin.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 41 I do not believe that it is feasible to add continuations to C++ for any number of reasons, but I would be interested to hear the reactions in this community regarding their utility in object-oriented programming. For those of you who are not already conversant with continuations, the idea comes from Scheme (though it has earlier antecedents), and looks like this: (call-with-current-continuation (lambda (continuation) (body...))) the call-with-current-continuation form potentially returns multiple times, because the continuation can be saved to a global variable. A subsequent invocation can be done with: (continuation value-producing-form) which causes a return from the call-with-current-continuation with that value. Logically, the continuation captures the future state of the program at the point at which it was captured. That is, it captures a pc, a set of registers, and a stack. Note that this implies garbage collection of stack frames, because a live frame in an enclosing context can be shared between a continuation and subsequent code. Continuations have seen use as error handlers, because they look like function invocations. One can set up an exception handling routine, capture it with a continuation, and use the continuation as a "longjump" type mechanism to get out of a bad state. Continuations are different from longjump in that they capture the stack as well as the registers. A detailed description can be found in the Revised Revised... Report on scheme, which can be obtained via anonymous FTP from zurich.ai.mit.edu. Jonathan Shapiro Silicon Graphics, Inc.