[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why are byte ports "ports" as such?
Marc Feeley scripsit:
> It is a pain to carry those two ports around in the code when the
> program needs to communicate bidirectionally with some other entity
> (another process, a user at a terminal, a socket, etc). Moreover the
> separation of a conceptually bidirectional channel into distinct
> ports (input and output) destroys the conceptual link that they
> have. This hinders program understanding. For example, with
> bidirectional ports (close-port port) will close both sides of the
> bidirectional port (i.e. the link between the input and output port
> is preserved). With two unidirectional ports you have to duplicate
> some operations (closing ports, changing port settings, ...).
I find this rationale convincing (and think it should be added to the
SRFI). However, the socket API does permit closing input and output
sides of the socket separately, and there are use cases for this, so it
should be at least permitted though not the default.
For example, when you want to send an arbitrary-length undecorated
document to a server and retrieve an arbitrary-length undecorated document
back, the simplest way to convey "end of document" is to close the output
side, while leaving the input side open in order to receive the reply.
A few unrelated editorial comments:
UTF-8 byte sequences of length 5 and 6 have been deprecated for a long,
long time. They should not be referred to here.
The SRFI should explicitly permit implementation-dependent encodings
and eol-encodings. (XML 1.1 allows CR, LF, CR/LF, NEL=U+0085, and
The SRFI should depend only on the lighter-weight SRFI 66 (Octet vectors),
rather than on the heavier-weight SRFI 4.
A warning is needed that non-default values of the create: file port
setting may be subject to race conditions on file systems that
don't provide full Posix semantics.
Finally, this SRFI makes only trivial use of keyword objects, and IMHO
should be respecified to use symbols to reduce its dependencies.
John Cowan firstname.lastname@example.org http://ccil.org/~cowan
This great college [Trinity], of this ancient university [Cambridge],
has seen some strange sights. It has seen Wordsworth drunk and Porson
sober. And here am I, a better poet than Porson, and a better scholar
than Wordsworth, somewhere betwixt and between. --A.E. Housman