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 stream word ; M:: throws-on-eof stream-read1 ( stream -- obj ) stream stream>> stream-read1 [ stream \ read1 stream-exhausted ] unless* ; M:: throws-on-eof stream-read ( n stream -- seq ) n stream stream>> stream-read dup length n = [ n stream \ read stream-exhausted ] unless ; M:: throws-on-eof stream-read-partial ( n stream -- seq ) n stream stream>> stream-read-partial [ n stream \ read-partial 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