Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!think!think.com!barmar From: barmar@think.com Newsgroups: comp.object Subject: Re: Continuations Message-ID: <31831@news.Think.COM> Date: 30 Nov 89 18:00:34 GMT References: <2664@bingvaxu.cc.binghamton.edu> <9624@pyr.gatech.EDU> <1623@odin.SGI.COM> <1663@odin.SGI.COM> <1419@cs.rit.edu> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA Lines: 34 In article <1419@cs.rit.edu> mjl@prague.UUCP (Michael Lutz) writes: >What is the essential difference between a continuation in Scheme and >the classic notion of a coroutine? I think a coroutine can only have one saved state at a time. Whenever you invoke a coroutine you return from the operation that last exited the coroutine. With continuations you can snapshot the state any number of times, and return to any one of them. Coroutines also don't permit you to return to functions that have already performed a normal return. Continuations do. >On a side note, aren't lexical scoping and continuations independent >concepts? Why I couldn't define a consistent language with >continuations where the meaning of a variable depends on the dynamic >invocation sequence rather than static nesting? I might not want to >*use* such a language (dynamic scoping makes it almost impossible to >understand a module/function in isolation) but that's an engineering >issue, not one of feasibility. I think you're right. I believe that the relationship between lexical scoping and continuations is more philosophical than architectural. I.e., lexical scoping and continuations are two aspects of a larger idea about programming, and they work well together. Also, continuation-based programming can be confusing, and lexical scoping makes it easier to understand what is going on. You are right that dynamic scoping makes it hard to understand modules (I was taught that it violates "referential transparency"), and adding continuations would make it even harder. Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar Brought to you by Super Global Mega Corp .com