1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel io destructors io.streams.plain ;
6 SINGLETONS: null-reader null-writer ;
7 UNION: null-stream null-reader null-writer ;
8 INSTANCE: null-writer plain-writer
10 M: null-stream dispose drop ;
12 M: null-reader stream-readln drop f ;
13 M: null-reader stream-read1 drop f ;
14 M: null-reader stream-read-until 2drop f f ;
15 M: null-reader stream-read 2drop f ;
17 M: null-writer stream-write1 2drop ;
18 M: null-writer stream-write 2drop ;
19 M: null-writer stream-flush drop ;
21 : with-null-reader ( quot -- )
22 null-reader swap with-input-stream* ; inline
24 : with-null-writer ( quot -- )
25 null-writer swap with-output-stream* ; inline