From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)' Date: Wed, 24 Nov 2010 00:44:54 +0100 Message-ID: <87d3pvli4p.fsf@delenn.lan> References: <87d3pyz5yo.fsf@delenn.lan> <1290377874-13808-3-git-send-email-a.rottmann@gmx.at> <8762vn3fro.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1290555928 10153 80.91.229.12 (23 Nov 2010 23:45:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 23 Nov 2010 23:45:28 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Nov 24 00:45:23 2010 Return-path: Envelope-to: guile-devel@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 1PL2Y4-0007jT-3X for guile-devel@m.gmane.org; Wed, 24 Nov 2010 00:45:20 +0100 Original-Received: from localhost ([127.0.0.1]:52991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL2Y3-0007xq-Gu for guile-devel@m.gmane.org; Tue, 23 Nov 2010 18:45:19 -0500 Original-Received: from [140.186.70.92] (port=49308 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL2Xp-0007w0-8E for guile-devel@gnu.org; Tue, 23 Nov 2010 18:45:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PL2Xn-0001AV-Tz for guile-devel@gnu.org; Tue, 23 Nov 2010 18:45:05 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:40470 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PL2Xn-0001AB-IC for guile-devel@gnu.org; Tue, 23 Nov 2010 18:45:03 -0500 Original-Received: (qmail invoked by alias); 23 Nov 2010 23:45:00 -0000 Original-Received: from 83-215-154-5.hage.dyn.salzburg-online.at (EHLO nathot.lan) [83.215.154.5] by mail.gmx.net (mp067) with SMTP; 24 Nov 2010 00:45:00 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX19bTh5oCy9bnr00vjZTF7rWBjyKDkR4JRbA7Hi7in yyTQ9Jvh7ipZkK Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id D574C3A695; Wed, 24 Nov 2010 00:44:59 +0100 (CET) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1zeWZIDFHlL5; Wed, 24 Nov 2010 00:44:55 +0100 (CET) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id BAC3F3A693; Wed, 24 Nov 2010 00:44:55 +0100 (CET) Original-Received: by delenn.lan (Postfix, from userid 1000) id 63EC42C05DB; Wed, 24 Nov 2010 00:44:55 +0100 (CET) In-Reply-To: <8762vn3fro.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 23 Nov 2010 22:13:15 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11192 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi Andreas, > > Looks good, but... > > Andreas Rottmann writes: > >> (call-with-port): Don't use `dynamic-wind', as it is against its >> specification in R6RS 8.2.6. > > [...] > >> (define (call-with-port port proc) >> "Call @var{proc}, passing it @var{port} and closing @var{port} upon e= xit of >> @var{proc}. Return the return values of @var{proc}." >> - (dynamic-wind >> - (lambda () >> - #t) >> - (lambda () >> - (proc port)) >> - (lambda () >> - (close-port port)))) >> + (call-with-values >> + (lambda () (proc port)) >> + (lambda vals >> + (close-port port) >> + (apply values vals)))) > > I don=E2=80=99t see what in =C2=A78.2.6 would be against =E2=80=98dynamic= -wind=E2=80=99,=20 > To quote that paragraph about `call-with-port': ,---- | Proc must accept one argument. The call-with-port procedure calls proc | with port as an argument. If proc returns, port is closed automatically | and the values returned by proc are returned. If proc does not return, | port is not closed automatically, except perhaps when it is possible to | prove that port will never again be used for an input or output | operation. `---- I interpreted that the way I did based on the question of what should happen when `proc' throws an exception (or otherwise invokes a continuation that makes it leave its current dynamic extent). To me, it seems that in this case, `proc' does not _return_, and hence the port should not be closed. Just to clarify, by a procedure "returning", I understand delivering a value (or values) to its continuation, which does not happen if the procedure invokes some arbitrary (other) continuation. FWIW, `call-with-port' is implemented without `dynamic-wind' in Ikarus, Ypsilon and Larceny. > and seems to > suggest that it=E2=80=99s OK. > Hmm, to me, the answer given to that comment does not really indicate whether the proposed implementation using `dynamic-wind' is acceptable or not (which is unfortunate). Regards, Rotty --=20 Andreas Rottmann --