io: error stream combinators
* with-error-stream(*) * with-output+error-stream(*) -- sets output and error stream to same stream * with-output>error -- sets output stream to error stream for scope * with-input-output+error-streams(*) -- like with-streams, but sets output and error to same streamdb4
parent
b237df3a3b
commit
d61f335fee
|
|
@ -62,6 +62,21 @@ SYMBOL: error-stream
|
||||||
: with-output-stream ( stream quot -- )
|
: with-output-stream ( stream quot -- )
|
||||||
[ with-output-stream* ] curry with-disposal ; inline
|
[ with-output-stream* ] curry with-disposal ; inline
|
||||||
|
|
||||||
|
: with-error-stream* ( stream quot -- )
|
||||||
|
error-stream swap with-variable ; inline
|
||||||
|
|
||||||
|
: with-error-stream ( stream quot -- )
|
||||||
|
[ with-error-stream* ] curry with-disposal ; inline
|
||||||
|
|
||||||
|
: with-output+error-stream* ( stream quot -- )
|
||||||
|
[ dup ] dip [ with-error-stream* ] curry with-output-stream* ; inline
|
||||||
|
|
||||||
|
: with-output+error-stream ( stream quot -- )
|
||||||
|
[ with-output+error-stream* ] curry with-disposal ; inline
|
||||||
|
|
||||||
|
: with-output>error ( quot -- )
|
||||||
|
error-stream get swap with-output-stream* ; inline
|
||||||
|
|
||||||
: with-streams* ( input output quot -- )
|
: with-streams* ( input output quot -- )
|
||||||
swapd [ with-output-stream* ] curry with-input-stream* ; inline
|
swapd [ with-output-stream* ] curry with-input-stream* ; inline
|
||||||
|
|
||||||
|
|
@ -71,6 +86,12 @@ SYMBOL: error-stream
|
||||||
#! buffer before closing the FD.
|
#! buffer before closing the FD.
|
||||||
swapd [ with-output-stream ] curry with-input-stream ; inline
|
swapd [ with-output-stream ] curry with-input-stream ; inline
|
||||||
|
|
||||||
|
: with-input-output+error-streams* ( input output+error quot -- )
|
||||||
|
swapd [ with-output+error-stream* ] curry with-input-stream* ; inline
|
||||||
|
|
||||||
|
: with-input-output+error-streams ( input output+error quot -- )
|
||||||
|
swapd [ with-output+error-stream ] curry with-input-stream ; inline
|
||||||
|
|
||||||
: print ( str -- ) output-stream get stream-print ; inline
|
: print ( str -- ) output-stream get stream-print ; inline
|
||||||
|
|
||||||
: bl ( -- ) " " write ;
|
: bl ( -- ) " " write ;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue