From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: gnuist006@gmail.com Newsgroups: gmane.emacs.help Subject: Re: The fundamental concept of continuations Date: Tue, 09 Oct 2007 06:34:22 -0000 Organization: http://groups.google.com Message-ID: <1191911662.983658.79540__5343.77671215243$1191912745$gmane$org@g4g2000hsf.googlegroups.com> References: <1191906949.179197.217470@57g2000hsv.googlegroups.com> <470b1b30$0$11022$4c368faf@roadrunner.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1191912740 25626 80.91.229.12 (9 Oct 2007 06:52:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 9 Oct 2007 06:52:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 09 08:52:18 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 1If8wy-00056J-7t for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Oct 2007 08:52:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1If8ws-0002Yw-Mb for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Oct 2007 02:52:10 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!g4g2000hsf.googlegroups.com!not-for-mail Original-Newsgroups: comp.lang.scheme, comp.lang.lisp, comp.lang.functional, gnu.emacs.help, comp.lang.python Original-Lines: 59 Original-NNTP-Posting-Host: 75.31.69.15 Original-X-Trace: posting.google.com 1191911663 15361 127.0.0.1 (9 Oct 2007 06:34:23 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 9 Oct 2007 06:34:23 +0000 (UTC) In-Reply-To: <470b1b30$0$11022$4c368faf@roadrunner.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g4g2000hsf.googlegroups.com; posting-host=75.31.69.15; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu comp.lang.scheme:74380 comp.lang.lisp:230760 comp.lang.functional:62587 gnu.emacs.help:152740 comp.lang.python:515501 X-Mailman-Approved-At: Tue, 09 Oct 2007 02:47:29 -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:48246 Archived-At: On Oct 8, 11:09 pm, "." wrote: > On Tue, 09 Oct 2007 05:15:49 +0000, gnuist006 wrote: > > 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 > > One of the lambda papers, I think. I don't remember which. > > > (2) its syntax and semantics in emacs lisp, common lisp, scheme > > elisp and Common Lisp don't have them (although sbcl and maybe others user > continuations internally). In scheme CALL-WITH-CURRENT-CONTINUATION takes > a function of one argument, which is bound to the current continuation. > Calling the continuation on some value behaves like > CALL-WITH-CURRENT-CONTINUATION returning that value. So > (call/cc (lambda (k) (k 42))) => 42 > You can think of it as turning the whatever would happen after call/cc > was called into a function. The most practical use for continuations in > implementing control structures, though there are some other neat tricks > you can play with them. > > > (3) Is it present in python and java ? > > Certainly not Java, I dunno about Python. I've never seen someone use > them in Python, but the pythonistas seem to want to add everything but a > decent lambda to their language so I wouldn't be surprised if someone had > added a call/cc. Ruby has it. > > > (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. > > You have Lisp in Small Pieces. Read Lisp in Small Pieces. > > > (5) how does it compare to and superior to a function or subroutine > > call. how does it differ. > > You use them like a function call. You can also use them like > setjmp/longjmp in C. You can implement coroutines with them, or > events, or simulate non-determinism or write things like ((call/cc call/cc) > (call/cc call/cc)) and make your head explode, use it like goto's inbred > second cousin or in general whatever perverse things you might like to do > with the flow of control in your program. > > > > > Thanks a lot. > > > (6) any good readable references that explain it lucidly ? > > Lisp in Small Pieces for implementation details, the Scheme Programming > Language for examples. which lambda paper ?