EchoStream.mesa
Copyright Ó 1990, 1992 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on September 20, 1990 9:26:09 am PDT
DIRECTORY IO;
EchoStream: CEDAR DEFINITIONS
= {
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.
}.