From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: continuation barriers Date: Wed, 26 Aug 2009 22:24:29 +0100 Message-ID: <87y6p6nu9e.fsf@arudy.ossau.uklinux.net> References: <3ae3aa420908231319y6cd4d189l4c1cab0a6b24283f@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251321892 3927 80.91.229.12 (26 Aug 2009 21:24:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Aug 2009 21:24:52 +0000 (UTC) Cc: Guile User To: linasvepstas@gmail.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 26 23:24:45 2009 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.50) id 1MgPz1-0005Tc-MK for guile-user@m.gmane.org; Wed, 26 Aug 2009 23:24:44 +0200 Original-Received: from localhost ([127.0.0.1]:45051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgPz0-00082A-V3 for guile-user@m.gmane.org; Wed, 26 Aug 2009 17:24:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgPyw-00080t-Mb for guile-user@gnu.org; Wed, 26 Aug 2009 17:24:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgPyr-0007zK-FO for guile-user@gnu.org; Wed, 26 Aug 2009 17:24:37 -0400 Original-Received: from [199.232.76.173] (port=40607 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgPyr-0007zH-AS for guile-user@gnu.org; Wed, 26 Aug 2009 17:24:33 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]:56951) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgPyr-0008W7-19 for guile-user@gnu.org; Wed, 26 Aug 2009 17:24:33 -0400 Original-Received: from arudy (host86-152-99-133.range86-152.btcentralplus.com [86.152.99.133]) by mail3.uklinux.net (Postfix) with ESMTP id DBD881F691E; Wed, 26 Aug 2009 22:24:31 +0100 (BST) Original-Received: from arudy.ossau.uklinux.net (arudy [127.0.0.1]) by arudy (Postfix) with ESMTP id 3423938021; Wed, 26 Aug 2009 22:24:30 +0100 (BST) In-Reply-To: <3ae3aa420908231319y6cd4d189l4c1cab0a6b24283f@mail.gmail.com> (Linas Vepstas's message of "Sun\, 23 Aug 2009 15\:19\:40 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 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:7420 Archived-At: Linas Vepstas writes: > i.e. I'd like something like this to work: > > scm_c_eval_string(" ... (call/cc (lambda (k) (set! *myk* k))) ..."); > ... some_c_code(...); > scm_c_eval_string(" ... (*myk* 42) ..."); I think there are a couple of problems here. The first is as you've noted, that scm_c_eval_string() has a scm_c_with_continuation_barrier() hiding inside it. You can avoid that by using some other method for calling from C into Scheme, for example: (define (entry-point code) ... set up whatever catches you want around the code that is going to be evaluated, e.g. for debugging ... (eval (with-input-from-string code read) (current-module)) ...) SCM entry_point_proc = SCM_VARIABLE_REF (scm_c_lookup ("entry-point")); scm_call_1 (entry_point_proc, code_string); The second is that you almost certainly don't want the continuation call to make C think it is returning again from the first scm_call_1 (). That kind of thing tends to confuse C code :-) I solved that problem (when I wanted to do something very like what you're doing) with an approach like this: (define current-c-code-continuation #f) (define (entry-point code) (call/cc (lambda (k) (set! current-c-code-continuation k) ... set up ... (as above) ... (eval (with- ...) ...) ... (as above) (current-c-code-continuation)))) > I think (I haven't yet tried) that the above can work if I wrap > the whole darn thing with scm_with_guile() .. but is there > some way of getting the above to run without a big wrap > of this kind? I don't think the above qualifies as "without a big wrap". But it did work. Regards, Neil