Tango I/O bug?

Jason House jason.james.house at gmail.com
Mon Sep 17 14:12:19 PDT 2007


Sean Kelly Wrote:

> Jason House wrote:
> > Typical offending code:
> > auto outStream = new Print!(char)(new Layout!(char),Stdout);
> 
> Is this really the line used?  The second parameter is supposed to be an 
> OutputStream, and Stdout is not.


No, I did a quick hack to make it short.  The code was more generic with the last input parameter being passed in from elsewhere.  I took a quick swag at it without verifying with other code.  The real code compiles ;)

Here's the key lines from the class:

Print!(char) outStream;
this(InputStream _inStream=Cin.stream, OutputStream _outStream=Cout.stream, double _pollPeriod=0.1){
  outStream = new Print!(char)(new Layout!(char),_outStream);
  ...


> > outStream.formatln("= {}\n", valueToReturn); // adds extra \n and flushes
> 
> Seems okay, though it's difficult to say from just that line.  Is output 
> redirected?  Are objects being re-used?  Is .close() perhaps not being 
> called if output is to a file?


Output is going to Cout.stream and is never closed.  The code relies on formatln to flush the output.  It does real time communication in plain text with a 3rd party controlling application.  This line really was from the program.  In this particular example, valueToReturn is of type char[] and is literally "HouseBot"


More information about the Digitalmars-d-learn mailing list