This makes it very difficult to read values. We can't retire din.readf before fixing this. import std.stdio; void main() { int i, j; readf("%s", &i); readf("%s", &j); } Run the program and provide the following as input: 42 43 The program terminates with std.conv.ConvError: std.conv(1070): Can't convert value `LockingTextReader(File(807637C), )' of type LockingTextReader to type int The reason is the white space.
This is by design. The example works when modified as follows: import std.stdio; void main() { int i, j; readf("%s", &i); readf(" %s", &j); } The space before the second parameter tells readf to read and skip all whitespace before attempting conversion. I've implemented readf to be a fair amount more Nazi about whitespace than scanf in an attempt to improve its precision. Scanf has been famously difficult to use for complex input parsing and validation, and I attribute some of that to its laissez-faire attitude toward whitespace. I'd be glad to relax some of readf's insistence on precise whitespace handling if there's enough evidence that that serves most of our users. I personally believe that the current behavior (strict by default, easy to relax) is best.
My apologies for forgetting about this bug report. I have since then replaced din and dout with stdin and stdout in D.ershane. The nazi whitespace behaviour worked correctly and consistently in all of the examples. Thank you, Ali
Let's keep it opened until the error message is fixed.
The original test case now produces this message: PS E:\DigitalMars\dmd2\samples> rdmd bug.d 456 45646 std.conv.ConvException@E:\DigitalMars\dmd2\windows\bin\..\..\src\phobos\std\conv.d(1779): Unexpected ' ' when converting from type LockingTextReader to type int
(In reply to Andrei Alexandrescu from comment #3) > Let's keep it opened until the error message is fixed. What is there to be fixed?(In reply to SomeDude from comment #4) > The original test case now produces this message: "Unexpected ' '" seems like an improvement, so I think this can now be closed.
alrighty