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?
Asked
Active
Viewed 1,477 times
1 Answers
4
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.

Dirk
- 30,623
- 8
- 82
- 102
-
Hm, well, I'm currently using version 1.0.45, I guess some revisions has happened since then. Isn't there any way for me to open my own bit-stream then? I'm aware of the existence of with-open-file but isn't that only used to open/create actual files? – Johan Jun 18 '11 at 15:29
-
You could try creating the streams from their FDs (0 stdin, 1 stdout, 2 stderr, see http://www.sbcl.org/manual/File_002ddescriptors.html). Disclaimer: haven't worked with these before myself. Might work. Might not... – Dirk Jun 18 '11 at 15:47
-
1Okay, I just updated SBCL to 1.0.49, I'll read the docs you sent me, thanks for your answer! EDIT: Hm, well, that's awful. It seems like it's actually SLIME who has a problem with this, well, I'll mock around on Google and try to find a solution. – Johan Jun 18 '11 at 15:55
-
@Johan You could also ask the Pros in the #lisp channel on freenode. I'm interested in this question. – whoplisp Jul 04 '11 at 00:39