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: Wed, 21 May 2014 16:24:35 +0200 Message-ID: <87fvk3mcpo.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1400682585 16151 80.91.229.3 (21 May 2014 14:29:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 May 2014 14:29:45 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed May 21 16:29:37 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 1Wn7WN-0004dx-Vy for guile-devel@m.gmane.org; Wed, 21 May 2014 16:29:32 +0200 Original-Received: from localhost ([::1]:60171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn7WN-0006Kq-IP for guile-devel@m.gmane.org; Wed, 21 May 2014 10:29:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn7S1-0007rR-SE for guile-devel@gnu.org; Wed, 21 May 2014 10:25:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wn7Rs-00072t-7p for guile-devel@gnu.org; Wed, 21 May 2014 10:25:01 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn7Rs-00071j-0b for guile-devel@gnu.org; Wed, 21 May 2014 10:24:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Wn7Ro-0006YI-DD for guile-devel@gnu.org; Wed, 21 May 2014 16:24:48 +0200 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 May 2014 16:24:48 +0200 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 May 2014 16:24:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 103 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 2 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 User-Agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:HShBplHMiPQykmxwPRQcXKCjxgw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:17154 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi! Doug Evans skribis: > The problem can be succinctly represented by the following: > > scheme@(guile-user)> (port? (port-with-print-state (current-output-port))) > $3 = #f I think the short answer is that it’s a very old API that’s essentially unused internally. For instance, make check passes with this patch: --=-=-= Content-Type: text/x-patch Content-Disposition: inline index 122e035..8f4c969 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -255,6 +255,7 @@ scm_free_print_state (SCM print_state) SCM scm_i_port_with_print_state (SCM port, SCM print_state) { + abort (); if (SCM_UNBNDP (print_state)) { if (SCM_PORT_WITH_PS_P (port)) @@ -596,8 +597,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate) SCM pwps, print = pstate->writingp ? g_write : g_display; if (SCM_UNPACK (print) == 0) goto print_struct; - pwps = scm_i_port_with_print_state (port, pstate->handle); - pstate->revealed = 1; + pwps = port; scm_call_generic_2 (print, exp, pwps); } else @@ -824,6 +824,7 @@ scm_prin1 (SCM exp, SCM port, int writingp) if (SCM_PORT_WITH_PS_P (port)) { + abort (); pstate_scm = SCM_PORT_WITH_PS_PS (port); port = SCM_PORT_WITH_PS_PORT (port); } @@ -1610,7 +1611,7 @@ scm_printer_apply (SCM proc, SCM exp, SCM port, scm_print_state *pstate) { pstate->revealed = 1; return scm_call_2 (proc, exp, - scm_i_port_with_print_state (port, pstate->handle)); + port); } SCM_DEFINE (scm_port_with_print_state, "port-with-print-state", 1, 1, 0, diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 42d7d78..2974ef6 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -1257,11 +1257,6 @@ VALUE." ;; ;; It should print OBJECT to PORT. -(define (inherit-print-state old-port new-port) - (if (get-print-state old-port) - (port-with-print-state new-port (get-print-state old-port)) - new-port)) - ;; 0: type-name, 1: fields, 2: constructor (define record-type-vtable (let ((s (make-vtable (string-append standard-vtable-fields "prprpw") --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 the meantime, I can make struct printers be aware of the > distinction and handle being passed port-with-print-state ports. Do you actually need this associated state? My first feeling is that we should deprecate and eventually remove this API, given that it’s essentially unused and non-functional. What do people think? > P.S. How come scm_put[cs]_unlocked are inlined in ports.h? What’s wrong with that? (It probably doesn’t help much because scm_lfwrite_unlocked isn’t inlined.) Ludo’. --=-=-=--