[Ecls-list] About unread-char and bidirectional streams
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Fri Jan 2 15:36:05 UTC 2009
On Thu, Jan 1, 2009 at 3:21 PM, Geo Carncross <geocar at gmail.com> wrote:
> My thinking is that ECL is wrong; Consider a bidirectional stream; what
> should write-char do after a unread-char? I think it should clobber the
> character read
It does so right now. I will upload the patches soon :-)
> (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) (finish-output s))
(file-position s)
(read-char s)
(file-position s)
(read-char s))))
(file-position s 0)
(print (read-line s)))
"abcdefghijk"
(0 #\a 1 NIL 0 #\x 1 #\b 2 #\c)
"xbcdefghijk"
"xbcdefghijk"
> (with-open-file (s "foo.txt" :direction :io :if-exists :supersede)
(write-line (print "ßçéî") 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 #\ç s) (finish-output s))
(file-position s)
(read-char s)
(file-position s)
(read-char s))))
(file-position s 0)
(print (read-line s)))
"ßçéî"
(0 #\U00df 2 NIL 0 #\U00e7 2 #\U00e7 4 #\U00e9)
"ççéî"
"ççéî"
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)
http://juanjose.garciaripoll.googlepages.com
More information about the ecl-devel
mailing list