From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thomas Girod Newsgroups: gmane.lisp.guile.user Subject: manipulating continuations Date: Sat, 12 Feb 2011 15:10:53 +0100 Message-ID: <4D5694ED.7080402@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297519894 8233 80.91.229.12 (12 Feb 2011 14:11:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Feb 2011 14:11:34 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Feb 12 15:11:27 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 1PoGC3-0004jF-Vj for guile-user@m.gmane.org; Sat, 12 Feb 2011 15:11:24 +0100 Original-Received: from localhost ([127.0.0.1]:39727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoGBz-00037b-3s for guile-user@m.gmane.org; Sat, 12 Feb 2011 09:11:19 -0500 Original-Received: from [140.186.70.92] (port=54278 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoGBi-000375-FT for guile-user@gnu.org; Sat, 12 Feb 2011 09:11:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoGBh-0006ar-CX for guile-user@gnu.org; Sat, 12 Feb 2011 09:11:02 -0500 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:45297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoGBh-0006aQ-5s for guile-user@gnu.org; Sat, 12 Feb 2011 09:11:01 -0500 Original-Received: by fxm12 with SMTP id 12so3880202fxm.0 for ; Sat, 12 Feb 2011 06:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=9ZJBnwx8XQ01QVeXgwfSb+wZwmV0ZLzbCBOmYhbxDEk=; b=sdEyn2frCQUTHez5Im4TJ/ouekdd5bo/xHTlk9UGynNTugucRDIk64mKX2Lm3tAjgx z8JMqSi1/a+mznOjdu1BG/U+RI6zg32PgH5UmB3Et0FjUfLNXnkYMMmb3w24UsKfywx3 yZgBLEEOzK8mPJnzWtuMbJ3vwua6nAPtWRQgE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=n+8eANxnNerfuIOzCe6NhqrH+G/HEWWlE4UtpR/fMkTQXbHNEwQiaRTZXLUGfB0gNl gkrwNBpyWstE1ZYNo4UWISFpRlXQjkilU8HXoDW3lH6u9Np5d2VmIHEBGmmFy3+tkM9d DKHOG9pzFOTVElCVo0h4G17VI/Yyl0nkIYmTg= Original-Received: by 10.223.96.67 with SMTP id g3mr1003882fan.114.1297519859917; Sat, 12 Feb 2011 06:10:59 -0800 (PST) Original-Received: from [192.168.0.10] (4ad54-1-88-172-90-158.fbx.proxad.net [88.172.90.158]) by mx.google.com with ESMTPS id b7sm190038faa.18.2011.02.12.06.10.56 (version=SSLv3 cipher=OTHER); Sat, 12 Feb 2011 06:10:58 -0800 (PST) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101227 Icedove/3.0.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 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:8426 Archived-At: Hello list I'm new to scheme and guile - started using them a few days ago for a project. So here we go: this is the bit of code that causing me troubles: (define (foo) (call/cc (lambda (return) (display "first part") (newline) (call/cc (lambda (cont) (return cont))) (display "second part") (newline)))) Basically, I use call/cc to stop the procedure foo after printing "first part" and return a continuation. Then, if I call this continuation it prints "second part" and ends. To test this code, I did this: 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* [#] :15:1: In expression ((foo)): :15:1: Wrong type to apply: # ABORT: (misc-error) There. I don't understand why I get this error message. Cheers Tom