On Sun, Jul 27, 2003 at 04:30:07PM +0100, Christophe Rhodes wrote:
> It looks mostly fine, but what happens (and, indeed, what _should_
> happen) if the requested file position is beyond the extent of the
> last index?
Sorry for the delay. As was pointed out by various people on #lisp,
both signalling an error and allowing the move beyond the end of
stream can indeed make sense -- at least in the case of an
I have a functional, but not extensively tested implementation, but it
requires rewriting unless we are willing to pay the price of all
string-input-streams-strings being non-simple. For
string-output-streams the cost is negligble.
The rewrite just means writing a specialized version of
string-input-streams to handle cases where the
string-input-stream-string is non-simple.
The simpler thing would be to signal an error when trying to move
file-position beyond the end of the string.
OTOH I am unsure if
(let ((s (make-string 3 :initial-element #\o)))
(with-string-input-stream (f s)
(setf (char s 0) #\f)
(read f))) => foo
is even legal, let alone required. I'm beginning to think that since
the spec talks about a subsequence of the string, it also means that
the above example should return ``ooo''. If so, moving beyond the end
of a string-input-stream makes much less sense.