From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matt Hellige Newsgroups: gmane.lisp.guile.user Subject: Re: Continuations: possible newbie question Date: Wed, 18 Dec 2002 12:14:10 -0600 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <20021218121410.A24945@metro.immute.net> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1040236402 3471 80.91.224.249 (18 Dec 2002 18:33:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 18 Dec 2002 18:33:22 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18Oj0Q-0000tS-00 for ; Wed, 18 Dec 2002 19:33:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18OiwX-0006cf-03 for guile-user@m.gmane.org; Wed, 18 Dec 2002 13:29:17 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18Oiw9-0006aE-00 for guile-user@gnu.org; Wed, 18 Dec 2002 13:28:53 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18Oiw7-0006ZS-00 for guile-user@gnu.org; Wed, 18 Dec 2002 13:28:52 -0500 Original-Received: from immute.net ([65.164.210.194]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Oiw7-0006ZO-00 for guile-user@gnu.org; Wed, 18 Dec 2002 13:28:51 -0500 Original-Received: (from matt@localhost) by immute.net (8.9.3/8.9.3) id MAA25023 for guile-user@gnu.org; Wed, 18 Dec 2002 12:14:11 -0600 Original-To: guile-user@gnu.org Mail-Followup-To: guile-user@gnu.org Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from ttn@giblet.glug.org on Wed, Dec 18, 2002 at 09:27:03AM -0800 X-Mailer-Holy-War: Get Mutt, it bites! X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1456 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1456 [Thien-Thi Nguyen ] > > is this due to a bug in guile, > > perhaps. here is what i see: > > guile> (version) > "1.4.1.93" > guile> (load "cwcc.scm") ; as posted > guile> (exec-binding bind) > "escaped" > guile> (done-reading "hi") > hi > guile> > Well, at this point it definitely seems to be a bug. I tried it in MIT Scheme as well, although I had to change my example not to use exceptions. Here's my new code snippet: (define call/cc call-with-current-continuation) (define cont #f) (define escape #f) (define (make-escape) (if (call/cc (lambda (c) (set! escape (lambda () (c #t))) #f)) (begin (display "escaped") (newline)) (begin (display "created escape proc") (newline)))) (define (get-string) (let ((result (call/cc (lambda (c) (set! cont c) #f)))) (if result result (begin (display "escaping... ") (escape))))) (define (done-reading result) (if cont (let ((tmp cont)) (set! cont #f) (tmp result)))) (define (bind) (display (get-string))(newline)) Here's what MIT Scheme does: 1 ]=> (make-escape) created escape proc ;Unspecified return value 1 ]=> (bind) escaping... escaped ;Unspecified return value 1 ]=> (done-reading "hi") hi ;Unspecified return value 1 ]=> (done-reading "there") ;Unspecified return value 1 ]=> which is exactly what I'd expect. Here's what Guile 1.6.0 does: guile> (make-escape) created escape proc guile> (bind) escaping... escaped guile> (done-reading "hi") (#) guile> (done-reading "there") guile> guile> (get-string) escaping... escaped guile> (done-reading "hi") "hi" guile> Obviously somewhat less violent than before, but apparently no more correct... Note that calling get-string directly still seems to work. Should I create an official bug report for this? What is the right procedure for doing so? > > another way to do what I'm trying to do? > > probably you can continue your explorations in this vein w/ more > debugging support: use `trace' and `pk' to determine where things go > wrong, and/or use a guile version that behaves as you expect. > > all other ways essentially devolve into using continuations. > Well, at this point I'm depending on 1.6, so that's not really an option. Plus, I just don't get the feeling that the claims that guile's non-linear continuations interact correctly with C code are totally reliable (especially since they seem to have problems even without C code!), so I'd prefer to avoid using them if possible. Which really just leaves me with only one choice: re-architect my project so that the problem goes away. I think that should be OK, now that I know it's what I need to do. I imagine someone who's been using Scheme for more than one week would probably have rather better ideas about this anyway... :) Thanks for your help, and please let me know what I should do to submit a bug report! Take care, Matt -- Matt Hellige matt@immute.net http://matt.immute.net _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user