Forum Navigation
Simpler console output?
Posted: 02/17/07 23:23:06Apparently there are a few different output functions to choose from in Stdout. This confused me a bit, since I was looking for a kind of be-all-end-all of output functions like writefln in phobos. So there's Stdout("..."); which is easy to type but lacks formatting outside of call chaining. Then there is Stdout.format("..."); and formatln which is longer to type but allows C# style formatting, which is cool. There is also Stdout.print and println, which seem to be the same as Stdout(); and Stdout().newline; (they almost don't seem worth mentioning in a reference doc).
Why not just do something like make Stdout allow formatting information, and make that the canonical console output function?
I also suggest mentioning in the docs that writefln style vararg formatting will not work here. Something to the effect that Stdout.formatln("The number is ",7,"."); will not do what you might think it does when coming from a phobos background.
I think I see why call chaining could be good for this now... Stdout.format("Hello World! The number is {0}\n",42)
("But now the number is {0}\n",43)();
... it would kill any ambiguity arising from multiple strings having formatting. But, that code I just mentioned doesn't do what I expect it to do. oh well.