From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: port-with-print-state doesn't create a port? Or, when is a port not a port? :-) Date: Mon, 26 May 2014 18:26:24 +0200 Message-ID: <87bnuko6a7.fsf@gnu.org> References: <87fvk3mcpo.fsf@gnu.org> <87mwe438ca.fsf@yeeloong.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1401121610 27118 80.91.229.3 (26 May 2014 16:26:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 May 2014 16:26:50 +0000 (UTC) Cc: guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon May 26 18:26:43 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WoxjV-0003QP-Fh for guile-devel@m.gmane.org; Mon, 26 May 2014 18:26:41 +0200 Original-Received: from localhost ([::1]:57628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoxjV-0002XV-1W for guile-devel@m.gmane.org; Mon, 26 May 2014 12:26:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoxjN-0002WU-JE for guile-devel@gnu.org; Mon, 26 May 2014 12:26:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoxjI-0005Iz-1v for guile-devel@gnu.org; Mon, 26 May 2014 12:26:33 -0400 Original-Received: from hera.aquilenet.fr ([2a01:474::1]:42288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoxjH-0005Ir-Qt for guile-devel@gnu.org; Mon, 26 May 2014 12:26:27 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8C3E92AF8; Mon, 26 May 2014 18:26:25 +0200 (CEST) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qS4SZXaQ4vY4; Mon, 26 May 2014 18:26:25 +0200 (CEST) Original-Received: from pluto (pluto.bordeaux.inria.fr [193.50.110.57]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 55CF1570; Mon, 26 May 2014 18:26:25 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Prairial an 222 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <87mwe438ca.fsf@yeeloong.lan> (Mark H. Weaver's message of "Mon, 26 May 2014 10:47:33 -0400") User-Agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:474::1 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:17161 Archived-At: Mark H Weaver skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Doug Evans skribis: >> >>> The problem can be succinctly represented by the following: >>> >>> scheme@(guile-user)> (port? (port-with-print-state (current-output-port= ))) >>> $3 =3D #f >> >> I think the short answer is that it=E2=80=99s a very old API that=E2=80= =99s essentially >> unused internally. [...] > [...] >> I think the problem it was trying to solve has been solved differently >> (by explicitly passing the print state in the print.c code, for >> instance), and can easily be solved differently. > > In order to implement SRFI-38 properly and efficiently, I think we need > to somehow pass the print state to user-defined structure printers. > Among other things, the print state includes a map from the set of > objects that are currently being printed (i.e. the ancestors of the > current object) to the associated datum label. > > Aside from proper SRFI-38 support, the print state is also used to > specify parameters such as maximum-depth for printing abbreviated > structures, used for example by the backtrace printer. Good points. > As distasteful as this 'port-with-print-state' concept may be, I'm not > aware of a better solution. Fluids aren't quite right, because a > structure printer might cause I/O to happen on another port. > > Another alternative would be to explicitly pass the print state to > structure printers, and then provide versions of 'write' and 'display' > that accept a separate print state argument, but we'd still need to > handle all the existing struct printers that don't know about this. > > Yet another option would be to move the print state into the port > itself. It might be worth considering, although it seems a bit unclean. Maybe the port alist you added a few months ago could be used to implement that actually, no? Thanks, Ludo=E2=80=99.