From: Marco Maggi <marco.maggi-ipsu@poste.it>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: binary-port?
Date: Sun, 24 Apr 2011 08:39:28 +0200 [thread overview]
Message-ID: <87bozwdufz.fsf@rapitore.luna> (raw)
In-Reply-To: <87liz0yc5l.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 23 Apr 2011 21:56:38 +0200")
Ludovic Courtès wrote:
>>> However, I’m wondering whether we should not just
>>> squarely do away with the binary/textual distinction
How would you handle port position? From R6RS[1]:
(port-has-port-position? port) procedure
(port-position port) procedure
The port-has-port-position? procedure returns #t if the
port supports the port-position operation, and #f
otherwise.
For a binary port, the port-position procedure returns
the index of the position at which the next byte would
be read from or written to the port as an exact
non-negative integer object. For a textual port,
port-position returns a value of some
implementation-dependent type representing the port’s
position; this value may be useful only as the pos
argument to set-port-position!, if the latter is
supported on the port (see below).
If the port does not support the operation,
port-position raises an exception with condition type
&assertion.
Note: For a textual port, the port position may or may
not be an integer object. If it is an integer object,
the integer object does not necessarily correspond to
a byte or character position.
(port-has-set-port-position!? port) procedure
(set-port-position! port pos) procedure
If port is a binary port, pos should be a non-negative
exact integer object. If port is a textual port, pos
should be the return value of a call to port-position on
port.
I do not know how current Guile handles ports; if
internally you mark a binary port to handle the position
char-wise (so that it is meant to be a textual port) and
BINARY-PORT? returns #t: what does GET-U8 do?
> Do you know what Industria, Nausicaa, & co. do?
Nausicaa uses BINARY-PORT? and TEXTUAL-PORT? only when
establishing the conventional class of a port value; as far
as I remember it does it in the same way GOOPS does to
dispatch multimethods.
IMHO this R6 statement:
(textual-port? port) procedure
(binary-port? port) procedure
The textual-port? procedure returns #t if port is
textual, and returns #f otherwise. The binary-port?
procedure returns #t if port is binary, and returns #f
otherwise.
should be enough to derive that:
(cond ((binary-port? p)
---)
((textual-port? p)
---))
and:
(cond ((textual-port? p)
---)
((binary-port? p)
---))
must be equivalent; if they are not, confusion arises
because of violation of the rule of least surprise.
[1] <http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-9.html#node_sec_8.2.6>
--
Marco Maggi
next prev parent reply other threads:[~2011-04-24 6:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-22 22:28 binary-port? Ludovic Courtès
2011-04-23 1:48 ` binary-port? Andreas Rottmann
2011-04-23 19:56 ` binary-port? Ludovic Courtès
2011-04-24 6:39 ` Marco Maggi [this message]
2011-04-24 13:03 ` binary-port? Ludovic Courtès
2011-04-25 11:55 ` binary-port? Andreas Rottmann
2011-04-25 14:08 ` binary-port? Ludovic Courtès
2011-04-25 14:20 ` binary-port? Andy Wingo
2011-04-26 0:16 ` binary-port? Andreas Rottmann
2011-04-26 15:00 ` binary-port? 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=87bozwdufz.fsf@rapitore.luna \
--to=marco.maggi-ipsu@poste.it \
--cc=guile-devel@gnu.org \
--cc=ludo@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).