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: binary-port? Date: Mon, 25 Apr 2011 13:55:50 +0200 Message-ID: <87hb9mwnnd.fsf@gmx.at> References: <871v0tudjg.fsf@gnu.org> <87sjt9agb5.fsf@gmx.at> <87liz0yc5l.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 1303732570 20526 80.91.229.12 (25 Apr 2011 11:56:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 25 Apr 2011 11:56:10 +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 Mon Apr 25 13:56:06 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QEKOb-0004gB-1a for guile-devel@m.gmane.org; Mon, 25 Apr 2011 13:56:05 +0200 Original-Received: from localhost ([::1]:40421 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEKOa-0001LK-CI for guile-devel@m.gmane.org; Mon, 25 Apr 2011 07:56:04 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:42480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEKOY-0001L9-I4 for guile-devel@gnu.org; Mon, 25 Apr 2011 07:56:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QEKOW-0004LK-TE for guile-devel@gnu.org; Mon, 25 Apr 2011 07:56:02 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:35867) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QEKOW-0004Kw-Dg for guile-devel@gnu.org; Mon, 25 Apr 2011 07:56:00 -0400 Original-Received: (qmail invoked by alias); 25 Apr 2011 11:55:57 -0000 Original-Received: from 83-215-154-5.hage.dyn.salzburg-online.at (EHLO nathot.lan) [83.215.154.5] by mail.gmx.net (mp013) with SMTP; 25 Apr 2011 13:55:57 +0200 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX19PDuIGUH9PzpVjfisl3VJ9Gr+0H5KgZcz1YhhZbG zbv0s7DStJ2dX3 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id E68673A69B; Mon, 25 Apr 2011 13:55:56 +0200 (CEST) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e78XUOAnYpKL; Mon, 25 Apr 2011 13:55:51 +0200 (CEST) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id 8BCAC3A696; Mon, 25 Apr 2011 13:55:51 +0200 (CEST) Original-Received: by delenn.lan (Postfix, from userid 1000) id 2C5922C00C8; Mon, 25 Apr 2011 13:55:51 +0200 (CEST) In-Reply-To: <87liz0yc5l.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sat, 23 Apr 2011 21:56:38 +0200") 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-Received-From: 213.165.64.23 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12339 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi Andreas! > > Andreas Rottmann writes: > >> ludo@gnu.org (Ludovic Court=C3=A8s) writes: > > [...] > >>> However, I=E2=80=99m wondering whether we should not just squarely do a= way with >>> the binary/textual distinction, and just write: >>> >>> (define (binary-port? p) #t) >>> >>> What do people with experience with pure R6RS code think? Is the >>> distinction actually used, and how? >>> >> I can only find one example in the code I wrote: >> `copy-port', which works (with the probably obvious semantics), on both >> binary and textual ports. On Guile, when `binary-port?' would return #t >> for all ports, `copy-port' would break, losing the transcoding effect >> you'd get when you pass two textual ports of different encodings. > > Interesting. Can you post a link to the code? > Sure, it's in `(spells ports)': https://github.com/rotty/spells/blob/master/spells/ports.sls > Anyway, that=E2=80=99s probably enough to keep the current semantics in 2= .0. > >> With the current behavior, you still have to watch the order of your >> port type checks, testing for `binary-port?' first, whereas on systems >> following R6RS strictly, you'd get the same behavior regardless of >> type check order. I can live with the latter, but the former would be >> unfortunate, IMHO. > > Do you know what Industria, Nausicaa, & co. do? > I don't have a copy of nausicaa lying around here, but in the R6RS code I have on my machine, xitomatl/ports.sls is the only other occurance of `binary-port?' (besides spells/ports.sls): http://bazaar.launchpad.net/~derick-eddington/scheme-libraries/xitomatl/vie= w/head:/ports.sls It's use there is in `open-compound-input-port': ;; A compound input port is a custom port which represents the logical ;; concatenation of other input ports. It starts out with an ordered ;; collection of input ports and reads from the first one until end of = file ;; is reached, whereupon it reads from the second one, and so on, until= end ;; of file is reached on the last of the contained input ports, and then ;; subsequent reads from the compound input port will return end of fil= e. ;; After each component port is exhausted, it is closed. Closing a com= pound ;; input port closes all remaining component ports. get-position and ;; set-position! are not supported. So, my impression is that while `binary-port?' and `textual-port?' are not used widely, they do have their uses, and there is definitly code out there that relies on the binary/textual distinction. > Likewise, any idea which Schemes have disjoint binary/textual ports, > and which don=E2=80=99t? > - Ikarus and Ypsilon definitly have disjoint ports. - Racket natively has ports that will accept both binary and textual operations, but it's R6RS support wraps these ports so that the resulting R6RS ports are not compatible with Racket's native port operations, but do provide the binary/textual disjointness. These are the only implementations (besides Guile), that I'm familiar with. Ideally, Guile's R6RS support would provide real disjointness for binary and textual ports -- I think the only artefact that hampers this is that there's no way to distinguish Latin-1 encoded ports from "pure" binary ports (as both have `port-encoding' being #f). Regards, Rotty --=20 Andreas Rottmann --