From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Non-stack-copying call-with-current-continuation? Date: Sun, 04 Mar 2012 19:42:55 +0100 Message-ID: <87y5rg8axc.fsf@pobox.com> References: <87ty27eus4.fsf@fencepost.gnu.org> <87mx7zesuw.fsf@fencepost.gnu.org> <87ipineqel.fsf@fencepost.gnu.org> <87eht9bmno.fsf@pobox.com> <87wr7060e6.fsf@fencepost.gnu.org> <87booca7er.fsf@pobox.com> <87sjho5uxb.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1330886595 7351 80.91.229.3 (4 Mar 2012 18:43:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 4 Mar 2012 18:43:15 +0000 (UTC) Cc: guile-devel@gnu.org To: David Kastrup Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Mar 04 19:43:14 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 1S4GOo-0007JK-Eb for guile-devel@m.gmane.org; Sun, 04 Mar 2012 19:43:14 +0100 Original-Received: from localhost ([::1]:58294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4GOn-0001Rn-Sv for guile-devel@m.gmane.org; Sun, 04 Mar 2012 13:43:13 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4GOk-0001Rh-H3 for guile-devel@gnu.org; Sun, 04 Mar 2012 13:43:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4GOi-0004xp-Gk for guile-devel@gnu.org; Sun, 04 Mar 2012 13:43:10 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:57885 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4GOe-0004xR-9X; Sun, 04 Mar 2012 13:43:04 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 6C0588AA6; Sun, 4 Mar 2012 13:43:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=/SEoA9h7YHzuH6enQrHI9s6k64w=; b=WFSb/F vy7nKz1Ms5nC8732bdVJN147S2isQoROdeJiOESBt3USW0VEWaoD9ORehhSz3cGD ZPHWav7GQ2lg+y4EJ4YvZ5LM0gn3RLtC+rSy2DJHoWX/jg/e1gIcwoWc2Tf3JVMq mQ4iTEgLrAPAX26KqRN7HKyWCnE33UptR2h40= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=WPusgata94uSnYiUXbh8KQd6pCp7qulJ THNqLFBNrzTDbI5rFKVrgtrz+/d+yRGL+T++ZolANTDK1UFlgyDKqe0JYyvX2uFC Cr2WRIF4Y7oWYIq+oo+sNyeJgXC8uutBYQFC4ZOOMhDwgrovFJ5NEcBUBjmhIis4 hX+aaTMNCKQ= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 5DA1F8AA5; Sun, 4 Mar 2012 13:43:00 -0500 (EST) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 96F748AA4; Sun, 4 Mar 2012 13:42:59 -0500 (EST) In-Reply-To: <87sjho5uxb.fsf@fencepost.gnu.org> (David Kastrup's message of "Sun, 04 Mar 2012 14:59:12 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: DDBC6F38-6629-11E1-BCD7-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 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:14002 Archived-At: Hello, On Sun 04 Mar 2012 14:59, David Kastrup writes: > Andy Wingo writes: > >> This is not true in Guile, where symbols can be garbage collected. > > The symbol name is not garbage collected. That is the difference > between gensym and make-symbol. Not sure I catch your meaning here... >> But you ask about a specific point, here: an abort to a prompt is >> basically boils down to a longjmp to the prompt's handler. The >> partial continuation is logically passed as an argument to the >> handler. > > But where does the "partial continuation" start and where does it end? It starts at the abort, and is delimited by the prompt. Or you can see it as the other way around. > If I am doing a "longjmp to the prompt's handler", how can it be that > the calling stack frame inside of the thunk that is supposed to be > exited can finish a calculation? You longjmp, yes: but after having reified (or not) the continuation. It's the continuation that lets you continue. > Where is the difference between > > (+ 34 (abort-to-prompt 'foo)) > > and > > (let ((x (abort-to-prompt 'foo))) (+ 34 x)) ? There is no semantic difference. > Why is the first allowed to complete and return a result, and the second > (presumably) not? Or _if_ the second is allowed to complete, what does > "abort" in "abort-to-prompt" even mean? Whether it is allowed to complete or not depends on the prompt's handler, as I mentioned before. Here is an analogy. Consider a prompt as creating a new process, in the UNIX sense. Consider "abort" as calling abort() and dumping core (or not). Consider calling the partial continuation as taking the core file and running it as a program (as used to be possible in some UNIX systems). Sometimes you enable cores because you are interested in them. Sometimes you just want to let a process quit and return a value. The analogy with reifying continuations or not is clear, I hope. > All this does not really make discernible sense to me. Whereas call/ec > has rather clear semantics and usage. Please do use call/ec, if you prefer its interface. > The one thing that is not self-evident is its behavior in case of > misuse, namely when it is asked to do a job only call/cc can. For the implementation based on "throw", you would get an error that would be caught by the nearest (catch #t ...). For prompts, you would get an error "abort to unknown prompt", which would also be caught by the nearest (catch #t ...), or a catch of `misc-error'. (Guile's error handling is not very systematic right now; something to work on.) Regards, Andy -- http://wingolog.org/