From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: George Neuner Newsgroups: gmane.emacs.help Subject: Re: The fundamental concept of continuations Date: Thu, 11 Oct 2007 03:18:34 -0400 Message-ID: References: <1191906949.179197.217470@57g2000hsv.googlegroups.com> <85zlyrutux.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1192096283 11737 80.91.229.12 (11 Oct 2007 09:51:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2007 09:51:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 11 11:51:21 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ifugy-0005uR-Ce for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Oct 2007 11:50:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ifugs-0000Gh-Bt for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Oct 2007 05:50:50 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Thu, 11 Oct 2007 02:18:41 -0500 Original-Newsgroups: comp.lang.scheme, comp.lang.lisp, comp.lang.functional, gnu.emacs.help, comp.lang.python X-Newsreader: Forte Agent 1.93/32.576 English (American) Original-Lines: 41 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 24.60.53.51 Original-X-Trace: sv3-S0M6BHvvDt1LVMj75kJnn89HF6AINcyVUI4kR1UYjoHYBJRwEM2rik+QLIbKpPaRMKbRjGxDm6doQqc!S6YcGfMKnZt5NMeHQC0mKF1ED3sFLRcKiliMwRyqUQS+jTPfdLZ/7K+pF6I6lrcBSNMk6Vw3PPbp!HNJoarjghqNOfH3G9kL1amzj Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.35 Original-Xref: shelby.stanford.edu comp.lang.scheme:74448 comp.lang.lisp:230946 comp.lang.functional:62632 gnu.emacs.help:152824 comp.lang.python:515839 X-Mailman-Approved-At: Thu, 11 Oct 2007 05:50:33 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:48330 Archived-At: On Wed, 10 Oct 2007 12:49:58 +0200, David Kastrup wrote: >gnuist006@gmail.com writes: > >> Again I am depressed to encounter a fundamentally new concept that I >> was all along unheard of. Its not even in paul graham's book where i >> learnt part of Lisp. Its in Marc Feeley's video. >> >> Can anyone explain: >> >> (1) its origin >> (2) its syntax and semantics in emacs lisp, common lisp, scheme >> (3) Is it present in python and java ? >> (4) Its implementation in assembly. for example in the manner that >> pointer fundamentally arises from indirect addressing and nothing new. >> So how do you juggle PC to do it. >> (5) how does it compare to and superior to a function or subroutine >> call. how does it differ. > >Basically, there is no difference to function/subroutine call. The >difference is just that there is no "call stack": the dynamic context >for a call is created on the heap and is garbage-collected when it is >no longer accessible. A continuation is just a reference to the state >of the current dynamic context. As long as a continuation remains >accessible, you can return to it as often as you like. Yes and no. General continuations, as you describe, are not the only form continuations take. Nor are they the most common form used. The most common continuations are function calls and returns. Upward one-shot continuations (exceptions or non-local returns) are the next most common form used, even in Scheme. Upward continuations can be stack implemented. On many CPU's, using the hardware stack (where possible) is faster than using heap allocated structures. For performance, some Scheme compilers go to great lengths to identify upward continuations and nested functions that can be stack implemented. George -- for email reply remove "/" from address