Xref: utzoo comp.object:524 comp.lang.c++:5708 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!odi!dlw From: dlw@odi.com (Dan Weinreb) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Continuations Message-ID: <1989Nov29.225826.19483@odi.com> Date: 29 Nov 89 22:58:26 GMT References: <2664@bingvaxu.cc.binghamton.edu> <9624@pyr.gatech.EDU> <1623@odin.SGI.COM> <1989Nov28.183816.15252@odi.com> <9964@june.cs.washington.edu> Reply-To: dlw@odi.com Organization: Object Design, Inc. Lines: 45 In-Reply-To: peterd@cs.washington.edu's message of 28 Nov 89 20:11:10 GMT In article <9964@june.cs.washington.edu> peterd@cs.washington.edu (Peter C. Damron) writes: In article <1989Nov28.183816.15252@odi.com> dlw@odi.com writes: >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, but I would be interested to hear the reactions > in this community regarding their utility in object-oriented programming. > >They are just as useful in object-oriented programming as in straight >Lisp or Scheme. How can you make this claim? Easy, I just press the keys, and... Seriously, I have used continuations in an object-oriented programming language (Lisp with Flavors), for years, as have several of my former colleagues. So I feel pretty qualified to claim that they're useful. Do you have any more specific rebuttal than amazement that I could even say such a thing? >However, continuations in the Scheme style are only >useful if full support is provided for lexical scoping. C and C++ >have no lexical scoping whatsoever. I just had to reply when I saw this. C and C++ are definitely "lexically scoped" (I would prefer to call it statically scoped). In a sense, C and C++ are lexically scoped, but only in a trivial sense, since there are no internal procedures and no block structure. So, you are technically right, and I should revise my statement to say that continuations are only useful if the continuation can reference variables of lexically enclosing blocks, and classic "continuation-passing style" in the Sussman and Steele sense requires further that they should be able to refer to such variables even if the enclosing block is no longer being executed (what is traditionally known in the Lisp/Scheme community as "supporting upward funargs"). Few languages support upward funargs; Common Lisp and Scheme are two that do. Many languages support downward funargs; Algol-60, Pascal, and PL/I come to mind. In C, you can pass a function around as an argument, but there is no "lexical link" allowing it to reference variables in its parent block; in fact, there are no parent blocks in C. (It can refer to static and extern, but that's not the same thing.) Dan Weinreb Object Design, Inc. dlw@odi.com Brought to you by Super Global Mega Corp .com