Open generic function
Reads the next element in a stream.
read-element input-stream #key on-end-of-stream
=> element-or-eof
<stream>.
<object>.
<object>.
io
streams
Returns the next element in the stream. If the stream is not at its end, the stream is advanced so that the next call to read-element returns the next element along in input-stream.
The on-end-of-stream keyword allows you to specify a value to be returned if the stream is at its end. If the stream is at its end and no value was supplied for on-end-of-stream, read-element signals an <end-of-stream-error> condition.
If no input is available and the stream is not at its end, read-element waits until input becomes available.
The following piece of code applies function to all the elements of a sequence:
let stream = make(<sequence-stream>, contents: seq); while (~stream-at-end?(stream)) function(read-element(stream)); end;