Xref: utzoo comp.object:561 comp.lang.c++:5747 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!sequent!mntgfx!plogan From: plogan@mentor.com (Patrick Logan) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Continuations Message-ID: <1989Nov30.002204.4899@mentor.com> Date: 30 Nov 89 00:22:04 GMT Organization: engr Lines: 43 >>From: grover%brahmand@Sun.COM (Vinod Grover) >In article <1623@odin.SGI.COM> shap@delrey.sgi.com (Jonathan Shapiro) writes: >>I do not believe that it is feasible to add continuations to C++ for >>any number of reasons... > >I do not know if you are talking about first-class continuations or not, but >in languages which are stack-based first-class continuations are not trivial >to add. (By stack-based I mean that the procedure entry exit sequance >behaves in a stack-like fashion) In C the idea of setjmp/longjump comes as >close to continuations as one can get. Admittedly, this is not as elegant as >Scheme's notion of continuation but workable in concept. > >> >>Jonathan Shapiro >>Silicon Graphics, Inc. > >Vinod Grover >Sun Microsystems. To be more accurate, longjump is not workable in concept because a longjump can only be executed once per setjmp. A continuation in Scheme can be captured once and executed zero or more times. Things become more complicated when you start considering nested setjmps and longjumps. For example, in my last article, I gave an example of a discrete event simulator. There is no way on Earth to implement that with setjmp and longjump. Essentially, setjmp/longjump implement a subset of what first-class continuations implement. There is no way to implement first-class continuations in C/C++ without fundamentally changing the semantics of the language. At that point, you have to poke yourself in the eye with a sharp object and ask yourself why do that? Have fun. -- Patrick Logan | ...!{decwrl,sequent,tessi}!mntgfx!plogan Mentor Graphics Corporation | plogan@pdx.MENTOR.COM Beaverton, Oregon | Brought to you by Super Global Mega Corp .com