Next Previous Up Top Contents Index

5.11 The STREAMS module

stream-at-end?

Open generic function

Summary

Tests whether a stream is at its end.

Signature

stream-at-end? stream => at-end? 

Arguments

stream
An instance of <stream>.

Values

at-end?
An instance of <boolean>.

Library

io

Module

streams

Description

Returns #t if the stream is at its end and #f if it is not. For input streams, it returns #t if a call to read-element with no supplied keyword arguments would signal an <end-of-stream-error>.

This function differs from stream-input-available?, which tests whether the stream can be read.

For output-only streams, this function always returns #f.

For output streams, note that you can determine if a stream is one place past the last written element by comparing stream-position to stream-size.

Example

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;

See also

<end-of-stream-error>, page 67

read-element, page 44

stream-input-available?, page 96


System and I/O Reference - 31 MAR 2000

Next Previous Up Top Contents Index