USING: accessors destructors io kernel locals namespaces sequences ; IN: io.streams.throwing throws-on-eof M: throws-on-eof stream-element-type stream>> stream-element-type ; M: throws-on-eof dispose stream>> dispose ; ERROR: stream-exhausted n stream ; M:: throws-on-eof stream-read1 ( stream -- obj ) stream stream>> stream-read1 [ 1 stream stream-exhausted ] unless* ; M:: throws-on-eof stream-read ( n stream -- seq ) n stream stream>> stream-read dup length n = [ n stream stream-exhausted ] unless ; M:: throws-on-eof stream-read-partial ( n stream -- seq ) n stream stream>> stream-read-partial [ n stream stream-exhausted ] unless* ; PRIVATE> : with-throws-on-eof ( stream quot -- ) [ ] dip with-input-stream ; inline : with-input-throws-on-eof ( quot -- ) [ input-stream get ] dip with-input-stream ; inline