WriteString["stderr", "[MathIO.m]"]; BeginPackage["MathIO`"]; Begin["`Private`"]; MathIO`pout::usage = "Prints its arguments to stdout; no implicit newline."; pout[stuff__] := WriteString["stdout", stuff] MathIO`perr::usage = "Prints its arguments to stderr; no implicit newline."; perr[stuff__] := WriteString["stderr", stuff] MathIO`read::usage = "Returns a line from STDIN (including the newline) or \"\" if EOF. TODO: this should read every character literally, not translate control characters! do what I'm doing with \\n's for others too."; read[prompt_:""] := Module[{x=InputString[prompt]}, If[x=="", "", StringDrop[StringReplace[x,"\n"->"\\n"],-2] <> "\n"] ] MathIO`readList::usage = "Returns a list of all the lines on STDIN."; readList[] := Take[NestWhileList[read[]&, "BOF", #!=""&], {2,-2}] MathIO`strout::usage = "Does ToString on its arguments and returns the concatenation."; strout[stuff___] := StringJoin@@(ToString/@{stuff}) End[]; (* Private context *) EndPackage[];