ECL distinguishes between two kinds of streams: character streams
and byte streams. In the first kind one is only allowed to write
characters, either individually, with write-char
, or
in chunks, with write-sequence
or any of the Lisp
printer functions. The implementation of character streams in ECL has the
following shortcomings:
No support for external formats. Reading and writing is performed using the 8-bit code of the character.
No support for Unicode characters. The code of large characters is simply truncated.
The other kind are binary streams. Here input and output is performed
in chunks of bits. Binary streams are created with the function
open
passing as argument a subtype of
integer. We distinguish two cases
The word size is a multiple of 8 bits: element types (byte 8), (signed-byte 32), etc.
The word size is not a multiple of 8 bits: element types (unsigned-byte 3), (signed-byte 15), etc.
In the first case the length of the file can be deduced from the number of octets which are used in the filesystem. In the second case, however, one needs some extra information which tells how many bits in the last byte are significant for the content. This information is stored as a single-byte header at the beginning of the file.