From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
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 [thread overview]
Message-ID: <87fvk3mcpo.fsf@gnu.org> (raw)
In-Reply-To: CAP9bCMQ414SO5uNiN8qzOQQEAz-2Q-D31nwHs_S3wAABGxvBcw@mail.gmail.com
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
Hi!
Doug Evans <xdje42@gmail.com> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1722 bytes --]
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")
[-- Attachment #3: Type: text/plain, Size: 698 bytes --]
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’.
next prev parent reply other threads:[~2014-05-21 14:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 18:10 port-with-print-state doesn't create a port? Or, when is a port not a port? :-) Doug Evans
2014-05-21 14:24 ` Ludovic Courtès [this message]
2014-05-25 19:05 ` Doug Evans
2014-05-26 14:47 ` Mark H Weaver
2014-05-26 16:26 ` Ludovic Courtès
2014-06-03 22:57 ` Mark H Weaver
2014-06-04 8:25 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvk3mcpo.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).