Subject: Unexpected (for me) behaviour of bivalent streams
Date: Thursday 24th November 2005 23:31:50 UTC (over 12 years ago)
On Windows with this function (defun foo (pathspec) (with-open-file (out pathspec :direction :output :if-exists :supersede) (write-sequence (make-array 1 :element-type '(unsigned-byte 8) :initial-element 10) out)) (with-open-file (in pathspec) (file-length in))) the result of, say, (FOO "/tmp/foo.txt") is 2 although only one octet was seemingly written to the stream. I can see how this happens - the stream is a bivalent stream and binary data written to the stream is treated like character data, so the 10 is viewed like a #\Newline character and converted to the CRLF combo. However, I find this kind of counter-intuitive. Furthermore, there seems to be no way to write a single literal octet "10" to the string, so in that sense the stream isn't fully "bivalent." What do others think? And what does LispWorks think? Is this the intended behaviour? Thanks, Edi.