Signaling errors for read-char/read-byte on binary/character streams?

Raymond Toy toy.raymond at gmail.com
Sun Oct 10 16:00:01 CEST 2010


 Previously with cmucl 19e and earlier, cmucl would signal errors if you
tried to read-char from a binary stream.  Similarly, read-byte would
signal an error from a character stream.  In 19f, this was also true,
except that read-char would work on (unsigned-byte 8) streams, and
read-byte would work on character streams.  And there was an addition to
support binary-text-streams where read-byte and read-char were always
allowed, and read-sequence was updated to work with any stream and read
the desired type of data from the stream.

In 20a and 20b, this was inadvertently broken when unicode was added. 
Now read-char and read-byte never signal errors on the the wrong type of
stream.  And even though they didn't signal errors, the results were not
right.  (read-byte and read-char behaved as if nothing else had been
read and continued where it left off.)

I think the we are required to signal errors for read-char on binary
streams and read-byte on character streams.  I propose that this should
be fixed now.  However, we will still allow binary-text-streams (created
using open :class 'binary-text-stream) to support so-called bivalent
streams.

I have the necessary changes to make this work, but the behavior of
read-sequence is changed.  If you want read-sequence to work as before,
you have to open the stream as a binary-text-stream.  (Making it work as
it used to will require some rethinking and reworking.)

Also, reading characters from binary-text-streams will be slower than in
20b, but the same as in 20a.  Reading characters from character streams
will still be as fast as in 20b.

Ray






More information about the cmucl-imp mailing list