Re: Reading a line from stdin

2011-03-16 Thread Gerrit Wichert
Am 16.03.2011 11:09, schrieb spir: This is a design bug. 99% of the time one does not want the newline, which is not part of the string data, instead just a terminator. Even more on stdin where it is used by the user to say "I"m done!". If the text is written back to the output /and/ newline is n

Re: Reading a line from stdin

2011-03-16 Thread Jesse Phillips
Kai Meyer Wrote: > Second, D doesn't seem to have a graceful way of reading an endless > stream of delimited by delimiting character>. I think readf is rigid, and works great in some > cases. I would greatly appreciate something more flexible like C++'s > extraction operator (operator>>) thou

Re: Reading a line from stdin

2011-03-16 Thread Kai Meyer
On 03/16/2011 07:54 AM, Ali Çehreli wrote: On 03/16/2011 05:49 AM, Kagamin wrote: Ali ǥhreli Wrote: The following program may be surprising to the novice: import std.stdio; void main() { write("What is your name? "); string name = readln(); writeln("Hi ", name, "!"); } What if the user typ

Re: Reading a line from stdin

2011-03-16 Thread Kagamin
Ali Çehreli Wrote: > I don't have a problem with whitespace being left in the line, I just > want to know whether that's the intended or accepted behavior. AFAIK, it is. It was intended to preserve eols while reading and writing lines.

Re: Reading a line from stdin

2011-03-16 Thread Jesse Phillips
spir Wrote: > On 03/16/2011 06:41 AM, Jesse Phillips wrote: > > Ali Çehreli Wrote: > > > >> Right? Is there a better way that I am missing? > >> > >> Thank you, > >> Ali > > > > No better way, the stated reason IIRC is that it is easier to remove the > > new line then to append it back on. > >

Re: Reading a line from stdin

2011-03-16 Thread Ali Çehreli
On 03/16/2011 05:49 AM, Kagamin wrote: Ali ǥhreli Wrote: The following program may be surprising to the novice: import std.stdio; void main() { write("What is your name? "); string name = readln(); writeln("Hi ", name, "!"); } What if the user typed leading spaces? Will th

Re: Reading a line from stdin

2011-03-16 Thread Kagamin
Ali ǥhreli Wrote: > The following program may be surprising to the novice: > > import std.stdio; > > void main() > { > write("What is your name? "); > string name = readln(); > writeln("Hi ", name, "!"); > } What if the user typed leading spaces? Will the program operate as you

Re: Reading a line from stdin

2011-03-16 Thread Lars T. Kyllingstad
On Wed, 16 Mar 2011 11:20:43 +0100, spir wrote: > On 03/16/2011 06:41 AM, Jesse Phillips wrote: >> Ali Çehreli Wrote: >> >>> Right? Is there a better way that I am missing? >>> >>> Thank you, >>> Ali >> >> No better way, the stated reason IIRC is that it is easier to remove >> the new line then to

Re: Reading a line from stdin

2011-03-16 Thread spir
On 03/16/2011 06:41 AM, Jesse Phillips wrote: Ali Çehreli Wrote: Right? Is there a better way that I am missing? Thank you, Ali No better way, the stated reason IIRC is that it is easier to remove the new line then to append it back on. May be stated, but it is very wrong! I guess: s

Re: Reading a line from stdin

2011-03-16 Thread spir
On 03/16/2011 06:05 AM, Ali Çehreli wrote: I am going over some sample programs in a text of mine and replacing std.cstream references with std.stdio. There are non-trivial differences with formatted input. The following program may be surprising to the novice: import std.stdio; void main() {

Re: Reading a line from stdin

2011-03-15 Thread Jonathan M Davis
On Tuesday 15 March 2011 22:05:37 Ali Çehreli wrote: > I am going over some sample programs in a text of mine and replacing > std.cstream references with std.stdio. There are non-trivial differences > with formatted input. > > The following program may be surprising to the novice: > > import std.

Re: Reading a line from stdin

2011-03-15 Thread Jesse Phillips
Ali Çehreli Wrote: > Right? Is there a better way that I am missing? > > Thank you, > Ali No better way, the stated reason IIRC is that it is easier to remove the new line then to append it back on.

Reading a line from stdin

2011-03-15 Thread Ali Çehreli
I am going over some sample programs in a text of mine and replacing std.cstream references with std.stdio. There are non-trivial differences with formatted input. The following program may be surprising to the novice: import std.stdio; void main() { write("What is your name? "); stri