Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!dptg!pegasus!psrc From: psrc@pegasus.ATT.COM (Paul S. R. Chisholm) Newsgroups: comp.object Subject: Re: Continuations Summary: continuations compatible with C and efficient subroutine calls? Message-ID: <4286@pegasus.ATT.COM> Date: 30 Nov 89 06:04:19 GMT References: <2664@bingvaxu.cc.binghamton.edu> <9624@pyr.gatech.EDU> <31794@news.Think.COM> <1623@odin.SGI.COM> <99894@ti-csl.csc.ti.com> Organization: AT&T Bell Laboratories Lines: 56 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 . . . In article <99894@ti-csl.csc.ti.com>, gateley@m2.csc.ti.com (John Gateley) writes: > I don't see why it would not be feasible, C++ has for loops and other > control structures, why not continuations as well? >John, gateley@m2.csc.ti.com "For loops and other control structures" just require conditional branches. Continuations require something for subroutine calling more complicated than a simple stack. Remember, many C++ implementations generate C code. If C++ provides a feature that can't be implemented in C, that whole method (which has made it much easier and faster to get object-oriented programming methods into the hands of programmers) goes down the tubes. In article <128489@sun.Eng.Sun.COM> grover@sun.UUCP (Vinod Grover) writes: > 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 article <31794@news.Think.COM>, barmar@think.com writes: > This is a circular argument. It's the very existence of first-class > continuations in Scheme-like languages that causes them not to be > stack-based. >Barry Margolin, Thinking Machines Corp., barmar@think.com, >{uunet,harvard}!think!barmar So you're saying that C++ (and by implication, C) would have to abandon their simple stacks in order to have first-class continuations? Efficiency (that is, allowing for the straightforward implementation of translators that produce efficient code) is one of the goals of the C++ programming languages. Even with inline functions, a C++ program will have lots of subroutine calls. A simple stack helps minimize the overhead of those calls. BTW, C++ class iterators either return a magic pointer, which can be trivially convinced to reference the next element, or separate iterator classes, which set aside memory (conceptually, and *very* roughly) like separate stack frames. They're not as elegant as iterators in Icon, CLU, or Smalltalk. I realize that continuations are useful for a *lot* more things than iteration. (Having said all that, I've painted myself into a corner: AT&T's C++ 2.0 library includes "tasks", a set of classes for coroutines. The library reference manual tells how they're implemented, but I've never read that part. Does anyone know how well the same techniques could be applied to continuations, first-class or otherwise?) Paul S. R. Chisholm, AT&T Bell Laboratories att!pegasus!psrc, psrc@pegasus.att.com, AT&T Mail !psrchisholm I'm not speaking for the company, I'm just speaking my mind. Brought to you by Super Global Mega Corp .com