2
votes

I want to be able to write bytes and read them from standard input/output but when I try this in SBCL I get the error "The stream has no suitable method[...]", why is this and how would I go about to make my own stream which can handle bytes?

1

1 Answers

4
votes

This seems to be because the standard input and output streams are streams with element type character, not (unsigned-byte 8). The element type of a stream is usually configured, when the stream is opened, which, in the case of standard input/output, is done automatically when the interpreter starts.

However, SBCL has the notion of bivalent streams, which can support both, character and byte-oriented I/O. As it happens, on my machine,

* (read-byte *standard-input* nil)
a

97
* (read-char *standard-input* nil)
a

#\a

works fine. So, which version of SBCL are you using? Mine is SBCL 1.0.49.