[streams-standard-discuss] Re: device-stream proposal
Bruno Haible
bruno at clisp.org
Thu Sep 16 20:47:44 UTC 2004
Rudi Schlatte wrote:
> This is a possible interface for "device object
> that can be plugged in a buffering layer" that can be implemented by a user.
Thanks Rudi for posting this.
Let me explain the differences w.r.t. the simple-streams proposal
(http://www.franz.com/support/documentation/6.0/doc/streams.htm,
http://www.franz.com/support/documentation/6.2/doc/streams.htm):
- The common thing is that it's about interfacing to low-level devices
that transport bytes. Examples: Sockets, ssh tunnels, gzipped data.
- The control-character processing has been removed from this layer.
Rationale: Since the control-character processing is limited to
bytes between 0 and 31, it's obviously meant for *terminal-io*, i.e.
for a stream whose speed is irrelevant. Such control-character processing
can be handled in upper layers without complicating the device layer.
- The external-format processing (conversion from byte sequence to
character sequence or multi-byte integer sequence) is left in an upper
layer. It is expected that the stream that does external-format processing
delegates to the device-stream.
- The buffering is left to an upper layer. An implementation can thus offer
buffered _or_ unbuffered streams that delegate to a user-written
device-stream. (Whereas buffering in the simple-streams proposal is
mandatory.)
The architecture thus looks like this:
Lisp stream
|
|
+----------------------------------+
| (optional) control |
| character processing |
| - provided by the implementation |
+----------------------------------+
|
|
Lisp stream
|
|
+----------------------------------+
| external-format processing |
| - provided by the implementation |
+----------------------------------+
|
|
Lisp stream
of element type (unsigned-byte 8)
|
|
+----------------------------------+
| (optional) buffering |
+----------------------------------+
|
|
Device-stream interface
|
|
+----------------------------------+
| a device-stream |
| provided by the user |
+----------------------------------+
- The device-read and device-write calling convention have been simplified
(no need to distinguish two kinds of EOF, no need for "no-hang queries"
since the caller can always pass a 1-byte buffer instead).
- The sequence type of the buffer is restricted to an array of
(unsigned-byte 8), to avoid typechecks inside device-read and
device-write.
Bruno
More information about the Streams-standard-discuss
mailing list