From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Neil Jerram" Newsgroups: gmane.lisp.guile.devel Subject: Re: `scm_c_read ()' and `swap_buffer' trick harmful Date: Thu, 20 Nov 2008 13:22:25 +0000 Message-ID: <49dd78620811200522k315281c8m9d952a17145b2479@mail.gmail.com> References: <87vduo92nj.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1227187368 9420 80.91.229.12 (20 Nov 2008 13:22:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Nov 2008 13:22:48 +0000 (UTC) Cc: guile-devel@gnu.org To: "=?ISO-8859-1?Q?Ludovic_Court=E8s?=" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Nov 20 14:23:51 2008 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.50) id 1L39Va-0003lx-M9 for guile-devel@m.gmane.org; Thu, 20 Nov 2008 14:23:46 +0100 Original-Received: from localhost ([127.0.0.1]:37301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L39UR-0002cB-JP for guile-devel@m.gmane.org; Thu, 20 Nov 2008 08:22:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L39UL-0002a5-77 for guile-devel@gnu.org; Thu, 20 Nov 2008 08:22:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L39UI-0002Xr-Ob for guile-devel@gnu.org; Thu, 20 Nov 2008 08:22:27 -0500 Original-Received: from [199.232.76.173] (port=37199 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L39UI-0002Xo-JC for guile-devel@gnu.org; Thu, 20 Nov 2008 08:22:26 -0500 Original-Received: from rv-out-0708.google.com ([209.85.198.240]:11481) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L39UI-0000IK-HZ for guile-devel@gnu.org; Thu, 20 Nov 2008 08:22:26 -0500 Original-Received: by rv-out-0708.google.com with SMTP id k29so479969rvb.6 for ; Thu, 20 Nov 2008 05:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=WptvclLBUU3LkwlRl/LSUZ9Gf+Jtk+viVtOv85lLxtw=; b=J/7scJVYyNh+PesYfnHGhVfzGlOw5C7pOS4qQQjsIZLjBfR6GRTUjFw2BbOaJ2fpGX pQPbtQGvso2Y4KD1N1wxU4Us2uTEpRndLlC5wiCPB4eh5DhJS2hqvrcXw463Wqt0iyzv JFm53c9IZQaQqTSu5vpjI61adawfmvbZlw7R8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=PrxUNX4O6Xqe74JuB7nj7atNZt1+uAJxtHccLxrtPfli2BvGTSFkIcgRH3REDbqHDD +9twHg/tB9jgiHxZnbos/bCZpXqn53ywU4rwJuXeSuTmmcuu8K1ypG4Jylc9ZBGsEMnd iMHf/wf9Of1sHlohHOnCxJiKPUSsAvhXqzLHM= Original-Received: by 10.140.193.15 with SMTP id q15mr1232976rvf.78.1227187345219; Thu, 20 Nov 2008 05:22:25 -0800 (PST) Original-Received: by 10.140.142.15 with HTTP; Thu, 20 Nov 2008 05:22:25 -0800 (PST) In-Reply-To: <87vduo92nj.fsf@gnu.org> Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:7867 Archived-At: 2008/11/15 Ludovic Court=E8s : > > So where to go from here? I think this example shows that the > `swap_buffer' trick is too risky, unfortunately. Thus, we may need to > revert it, at least in 1.8. Second, I think that a `read' method as a > replacement for `fill_input', as I proposed back then [3], would be > safer; maybe 1.9 would be a nice place to add it. Neil: what do you > think? I think this means we should only do the swap_buffer trick for unbuffered ports. That would solve the original problem, and avoid breaking cases like this. It _could_ be argued that cbip_fill_input() should take more care to use the port's actual current buffer. e.g. it should construct a new R6RS bytevector around the current port->read_buf, and pass that to the read! procedure. But I'm not going to argue that, because the generalization of that would be to say that C code that implements a buffered port cannot assume that the buffer stays as originally set; and, with hindsight, it seems that C code _should_ be able to rely on this. (Plus constructing a new bytevector would probably be bad for performance.) I recall you queried before whether we should apply this fix to buffered ports too, and I confidently said yes; sorry about that! Do you agree that doing the trick only for unbuffered ports would be a good approach? If so I'll see what that means in terms of code. Neil