11.1.4 Input-Output System
The internals of the I/O subsystem have been completely
redesigned. The new version should be faster while at the same time
providing more functionality and more consistent behavior between
operating systems and between stream types.
The semantics of character codes has been fixed as (a superset of)
Unicode. Redefining the meaning of character codes is no longer
supported.
New features and changes to the SICStus streams (SP_stream
)
include:
- Streams are binary or text also at the lowest level, e.g. in the C
API, and there are separate operations for performing I/O of bytes and
characters.
- Streams have a layered design. This makes it possible to add character
set translation and other transformations (compression, encryption,
automatic character set detection, ...) to any stream.
- All streams provide non-blocking operations and are interruptible,
e.g. with ^C (‘SIGINT’). This is also true for file
streams and under Windows.
- Subject to OS limitations, file names can use Unicode and be of
arbitrary length. In particular, under Windows, the Unicode API is used
for all operations.
- Limits on file size, file time stamps etc have been removed.
- Error handling has been simplified and made more consistent. In the C
API all I/O operations return an error code from a rich set of error
codes. Errors during write and close operations are no longer ignored.
- It is possible to wait for I/O ready (both for read and write) on any
type of stream. This works for all platforms, including
Windows. Select operations wait for the appropriate item type, e.g.
until a whole (possibly multi-byte) character can be transferred on a
text stream.
Other minor changes:
- Now
byte_count/2
can be called only on binary streams.
at_end_of_stream/[0,1]
never blocks. Instead it will fail, i.e.
behave as if the stream is not at its end, if the operation would
otherwise block. See at_end_of_stream/[0,1]
.
Send feedback on this subject.