CreateEchoStream:
PROC [in, out:
IO.
STREAM, mapErrors:
BOOL ¬
TRUE, eraseBackup, resetOutput, closeIn, closeOut:
BOOL ¬
FALSE]
RETURNS [
IO.
STREAM];
GetChar[result] = {c: CHAR ~ in.GetChar[]; out.PutChar[c]; RETURN [c]}, approximately.
GetIndex[result] = 0 at first. GetIndex[result] takes PutBack into account.
Iff mapErrors, errors arising from in and out will be mapped into errors on result.
If eraseBackup, backed up chars will be erased from out, and re-output later; otherwise, backed up chars will only be output once - the first time they're read.
Iff resetOutput, Reset[result] will Reset[out]. Reset[result] always Resets in.
Close[result] closes in and out iff closeIn and closeOut, respectively.
}.