From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: Non-stack-copying call-with-current-continuation? Date: Sat, 03 Mar 2012 06:03:34 +0100 Message-ID: <87y5riwa1l.fsf@rotty.yi.org> References: <87ty27eus4.fsf@fencepost.gnu.org> <87mx7zesuw.fsf@fencepost.gnu.org> <87ipineqel.fsf@fencepost.gnu.org> <87ehtbe6vx.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1330751056 20980 80.91.229.3 (3 Mar 2012 05:04:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 3 Mar 2012 05:04:16 +0000 (UTC) Cc: guile-devel@gnu.org To: David Kastrup Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Mar 03 06:04:13 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S3h8a-00022h-0q for guile-devel@m.gmane.org; Sat, 03 Mar 2012 06:04:08 +0100 Original-Received: from localhost ([::1]:41446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3h8Z-000309-7t for guile-devel@m.gmane.org; Sat, 03 Mar 2012 00:04:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3h8D-0002zo-Uc for guile-devel@gnu.org; Sat, 03 Mar 2012 00:04:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3h8B-0003Eh-RN for guile-devel@gnu.org; Sat, 03 Mar 2012 00:03:45 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:58892) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1S3h8B-0003DE-ID for guile-devel@gnu.org; Sat, 03 Mar 2012 00:03:43 -0500 Original-Received: (qmail invoked by alias); 03 Mar 2012 05:03:41 -0000 Original-Received: from 85-127-55-239.dynamic.xdsl-line.inode.at (EHLO nathot.lan) [85.127.55.239] by mail.gmx.net (mp032) with SMTP; 03 Mar 2012 06:03:41 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX1/AKTMjsLHAVZxYeVSN5G2TgJ8rJXTCQqi+DFb0NJ 8JudcLyf+YOQt3 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id B78D13A696; Sat, 3 Mar 2012 06:03:39 +0100 (CET) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JrswzWz66c+V; Sat, 3 Mar 2012 06:03:34 +0100 (CET) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id D4E1B3A68F; Sat, 3 Mar 2012 06:03:34 +0100 (CET) Original-Received: by delenn.lan (Postfix, from userid 1000) id 9F53C3A2DED; Sat, 3 Mar 2012 06:03:34 +0100 (CET) In-Reply-To: <87ehtbe6vx.fsf@fencepost.gnu.org> (David Kastrup's message of "Fri, 02 Mar 2012 09:36:50 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.22 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13984 Archived-At: David Kastrup writes: > Noah Lavine writes: > >> Hello, >> >>> Sure, but things like gensym and make-prompt-tag (and (list '()) for >>> creating an eq?-unique object) are artificial hygiene coming at a cost >>> in symbol table and symbol generation time rather than "lexical" >>> hygiene. =C2=A0They need _extra_ work, whereas the >>> call-with-current-continuation approach needed _less_ work. =C2=A0Basic= ally I >>> want something like call-with-single-continuation that will only allow >>> one return (and any dynwind out counts and should work if it is the >>> first, so it is not exactly equivalent to using >>> with-continuation-barrier) and come without the stack-copying cost of >>> call-with-current-continuation. >> >> I agree that it's not pretty. We have hygienic macros so we don't have >> to use gensym, after all. But I don't know of a better way. > > Well, to wrap this up: the manual (not current) states > > It is traditional in Scheme to implement exception systems using > `call-with-current-continuation'. Continuations (*note > Continuations::) are such a powerful concept that any other control > mechanism -- including `catch' and `throw' -- can be implemented in > terms of them. > > [...] > > The more targeted mechanism provided by `catch' and `throw' does n= ot > need to save and restore the C stack because the `throw' always jumps > to a location higher up the stack of the code that executes the > `throw'. Therefore Guile implements the `catch' and `throw' primitiv= es > independently of `call-with-current-continuation', in a way that takes > advantage of this _upwards only_ nature of exceptions. > > > I think that using something like "call-with-single-continuation" as the > underlying primitive would make Guile quite more similar to > "traditional" systems in the code base. It would also provide a > minimally-invasive tool for tuning existing code based on > call-with-current-continuation in case that the stack copying semantics > are _not_ required. Definitely more Schemeish than stuff like, uh, > prompts? > Just to throw my two cents in: Racket (and probably other Schemes) provide this primitive under the name call-with-escape-continuation (call/ec): http://docs.racket-lang.org/reference/cont.html?q=3Dcall/ec#%28def._%28%28q= uote._~23~25kernel%29._call-with-escape-continuation%29%29 Regards, Rotty --=20 Andreas Rottmann --