Re: readf for the novice

2010-09-06 Thread Andrej Mitrovic
Those look really nice, they could especially be used in tutorials. I'm replicating some D1 examples from the dsource page to be D2 compatible, and I could add a bunch of more D2 examples as well. I'd be willing to write some tutorials for these if they get their way into Phobos. Jesse Philli

Re: readf for the novice

2010-08-17 Thread Jesse Phillips
Mafi Wrote: > That sounds really cool. Having things like this in the std lib would > allow you to write great consistent utilities with simple and short > code. If such functions will ever get into phobos (what I really hope), > they should get their own module. What do you thinke about > 'st

Re: readf for the novice

2010-08-17 Thread Mafi
Am 17.08.2010 19:10, schrieb Jesse Phillips: Ali �ehreli Wrote: A novice should be able to read as simple as auto d = read!double(); auto i = read!int(); Ignoring stripping whitespace, read can be implemented like this: T read(T)() { T value; readf("%s",&value);

Re: readf for the novice

2010-08-17 Thread Jesse Phillips
Ali Çehreli Wrote: > A novice should be able to read as simple as > > auto d = read!double(); > auto i = read!int(); > > Ignoring stripping whitespace, read can be implemented like this: > > T read(T)() > { > T value; > readf("%s", &value); > return value; > } > > Ali

Re: readf for the novice

2010-08-16 Thread Ali Çehreli
Sean Kelly wrote: > Ali Çehreli Wrote: >> int i; >> int j; >> >> readf("%s", &i); >> readf("%s", &j); >> >> When the input is >> >> 42 43 >> >> the output is >> >> std.conv.ConvError: std.conv(1070): Can't convert value >> `LockingTextReader(File(807637C), )' of type LockingTe

Re: readf for the novice

2010-08-16 Thread Sean Kelly
Ali Çehreli Wrote: > Since cstream is deprecated and stdio.readf is finally available with > 2.048, I started modifying my D book by replacing code like > > T var; > din.readf(&var); > > with > > T var; > readf("%s", &var); > > > 1) I couldn't go far, because stdio.readf

readf for the novice

2010-08-16 Thread Ali Çehreli
Since cstream is deprecated and stdio.readf is finally available with 2.048, I started modifying my D book by replacing code like T var; din.readf(&var); with T var; readf("%s", &var); 1) I couldn't go far, because stdio.readf does not ignore whitespace and code like the fol