From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel@gnu.org
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 [thread overview]
Message-ID: <87bnuko6a7.fsf@gnu.org> (raw)
In-Reply-To: <87mwe438ca.fsf@yeeloong.lan> (Mark H. Weaver's message of "Mon, 26 May 2014 10:47:33 -0400")
Mark H Weaver <mhw@netris.org> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> 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. [...]
> [...]
>> 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’.
next prev parent reply other threads:[~2014-05-26 16:26 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
2014-05-25 19:05 ` Doug Evans
2014-05-26 14:47 ` Mark H Weaver
2014-05-26 16:26 ` Ludovic Courtès [this message]
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=87bnuko6a7.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=mhw@netris.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).