Okay, this works:<br><br>import std.conv, std.stdio;<br><br>void writeln(T...)(T args)<br>{<br> foreach (arg; args)<br> {<br> stdout.rawWrite(to!string(arg));<br> }<br> stdout.rawWrite("\n");<br>
stdout.flush();<br>}<br><br>void main()<br>{<br> writeln("test");<br>}<br><br>But I had to replace '\n' with "\n", otherwise I get some errors back:<br><br>test.d(11): Error: template std.stdio.File.rawWrite(T) does not match any function template declaration<br>
test.d(11): Error: template std.stdio.File.rawWrite(T) cannot deduce template function from argument types !()(char)<br>test.d(17): Error: template instance test.writeln!(string) error instantiating<br><br>Which probably makes sense if rawWrite expects a string and not a char.<br>
<br>Thanks Jonathan.<br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 8:52 PM, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisprog@gmail.com">jmdavisprog@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Wednesday, August 04, 2010 11:38:28 Andrej Mitrovic wrote:<br>
> From TDPL, page 161:<br>
><br>
> import std.conv;<br>
><br>
> void writeln(T...)(T args)<br>
> {<br>
> foreach (arg; args)<br>
> {<br>
> stdout.rawWrite(to!string(arg));<br>
> }<br>
> stdout.rawWrite('\n');<br>
> stdout.flush();<br>
> }<br>
><br>
> void main()<br>
> {<br>
> writeln("test");<br>
> }<br>
><br>
> test.d(10): Error: undefined identifier stdout<br>
<br>
</div></div>std.stdio - which is what you usually import for doing I/O. Of course, it<br>
actually defines writeln(), so it's not like you need to write it yourself - not<br>
to mention, you can always just look at stdio.d in the phobos src (which gets<br>
downloaded with dmd) to see its exact implementation if you want to.<br>
<font color="#888888"><br>
- Jonathan M Davis<br>
</font></blockquote></div><br>