From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Re: manipulating continuations Date: Sat, 12 Feb 2011 16:43:59 +0100 Message-ID: References: <4D5694ED.7080402@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1297525329 648 80.91.229.12 (12 Feb 2011 15:42:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Feb 2011 15:42:09 +0000 (UTC) Cc: guile-user@gnu.org To: Thomas Girod Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Feb 12 16:42:05 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PoHbo-0003cu-FJ for guile-user@m.gmane.org; Sat, 12 Feb 2011 16:42:04 +0100 Original-Received: from localhost ([127.0.0.1]:48880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoHbn-0006ru-OA for guile-user@m.gmane.org; Sat, 12 Feb 2011 10:42:03 -0500 Original-Received: from [140.186.70.92] (port=57147 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoHYv-0005Jn-HW for guile-user@gnu.org; Sat, 12 Feb 2011 10:39:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoHYu-0001jD-AS for guile-user@gnu.org; Sat, 12 Feb 2011 10:39:05 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:40005 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoHYu-0001j8-3h for guile-user@gnu.org; Sat, 12 Feb 2011 10:39: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 57C22254A; Sat, 12 Feb 2011 10:40:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=NXbptQ731hxndp80JmECv261GnM=; b=W7DcuT f1QhrOLsvaLeNxqWiH5YSL0zbe+tZNoWOZFWCWIsL+0kA4xNqtMzFuimd0kFHxwe Yih2cIr/g9cKlRPRlXAIWurwQo+pvFR1ZO660GsyBLH0sDpTureye9WHt+Y0wPax F0xOJFFvmbvaC6l8tYn1B6MRkZ9SdNIw80itk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; q=dns; s=sasl; b=ubyqC9rPRKA7YviCdCHtZS+3uTDj/F2E EcC7UZDTqUQGguO1H9VsA5LI9oxmTCjpsu/iMzXnzytOrobthgYKec1sjdUlqTHd uE7e5/KNPW0qBFpsBIkDLn9F28GochEM+vefIFxNWtvF32kjLI0oiqvr6gCii5e2 QloytxmYoQM= 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 446F82549; Sat, 12 Feb 2011 10:40:04 -0500 (EST) Original-Received: from unquote.localdomain (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 BCCCB2548; Sat, 12 Feb 2011 10:40:01 -0500 (EST) In-Reply-To: <4D5694ED.7080402@gmail.com> (Thomas Girod's message of "Sat, 12 Feb 2011 15:10:53 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 5C5D169A-36BE-11E0-A0A4-AF401E47CF6F-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8428 Archived-At: Hi Thomas, On Sat 12 Feb 2011 15:10, Thomas Girod writes: > (define (foo) > (call/cc > (lambda (return) > (display "first part") > (newline) > (call/cc > (lambda (cont) > (return cont))) > (display "second part") > (newline)))) > > guile> (define c (foo)) > first part > guile> (c) > second part > > yay, it works. But now, what if I want to run the continuation directly, > rather than storing it and calling it later ? This is what I get: > > guile> ((foo)) > first part > second part > > Backtrace: > In current input: > 15: 0* [#] In this expression, `foo' has returned twice. The first time it returned a continuation, which was applied. The second time it returned whatever `newline' returned: the unspecified value. Applying the unspecified value failed. If you use Guile 1.9/2.0, partial continuations behave more in the way you were thinking of: (use-modules (ice-9 control)) (define (foo) (% (begin (display "first part\n") (abort) (display "second part\n")) (lambda (cont) ;; abort jumps back here, to the handler. return the partial ;; continuation. cont))) scheme@(guile-user)> (foo) first part $1 = # scheme@(guile-user)> ($1) second part scheme@(guile-user)> ((foo)) first part second part scheme@(guile-user)> Have fun with Guile, Andy -- http://wingolog.org/