[Openmcl-devel] Bidirectional streams

Daniel Herring dherring at tentpost.com
Wed Jan 7 20:01:00 PST 2009


Hi,

A current cll thread with the same subject has been exploring the behavior 
of read-char and unread-char on bidirectional streams.

A recent post provided the following test.

(with-open-file (s "foo.txt" :direction :io :if-exists :supersede)
   (write-line (print "abcdefghijk") s)
   (file-position s 0)
   (let (a)
     (print (list (file-position s)
                  (setf a (read-char s))
                  (file-position s)
                  (unread-char a s)
                  (file-position s)
                  (prog1 (write-char #\x s) (force-output s))
                  (file-position s)
                  (read-char s)
                  (file-position s)
                  (read-char s))))
   (file-position s 0)
   (print (read-line s)))


This fails to run on clozure...

Welcome to Clozure Common Lisp Version 1.3-dev-r11532M-trunk (LinuxX8664)!
...
"abcdefghijk"
> Error: Unexpected end of file on #<BASIC-FILE-CHARACTER-IO-STREAM ("foo.txt"/4 ISO-8859-1) #x3000416F06BD>, near position 12
> While executing: CCL::READ-CHAR-INTERNAL, in process listener(1).


Is this poorly written code, or does it expose a bug in clozure?

Thanks,
Daniel



More information about the Openmcl-devel mailing list