Lisp HUG Maillist Archive

READ-BYTE/WRITE-BYTE and bivalent streams

So, instead of just (READ-BYTE STREAM) I'm currently using a kludge
like

  (let ((buffer (make-array 1 :element-type '(unsigned-byte 8))))
    (read-sequence buffer in)
    (aref buffer 0))

which, er, looks kind of uncool to me.  Same for WRITE-BYTE.

Does someone here have a nicer solution?

To LispWorks: Do you have plans to make READ/WRITE-BYTE adhere to
bivalent streams in LW 5.0?


Re: READ-BYTE/WRITE-BYTE and bivalent streams

Hello Edi,

| So, instead of just (READ-BYTE STREAM) I'm currently using a kludge
| like
|
|   (let ((buffer (make-array 1 :element-type '(unsigned-byte 8))))
|     (read-sequence buffer in)
|     (aref buffer 0))
|
| which, er, looks kind of uncool to me.  Same for WRITE-BYTE.
|
| Does someone here have a nicer solution?

I would recommend opening a stream with both :external-format and
:element-type '(unsigned-byte 8). At least for output, the stream behaves
like bivalent - you can use both  write-byte and write-char (provided the
char is a base-char).
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


Updated at: 2020-12-10 08:50 UTC