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

Re: I seem to be able to crash writefln

2011-03-15 Thread Joel Christensen
On 15/03/2011 1:57 a.m., Steven Schveighoffer wrote: On Fri, 11 Mar 2011 18:57:32 -0500, Spacen Jasset wrote: On 10/03/2011 12:18, Steven Schveighoffer wrote: On Wed, 09 Mar 2011 18:19:55 -0500, Joel Christensen wrote: This is on Windows 7. Using a def file to stop the terminal window comi

Re: Best practice for strings across D1 and D2

2011-03-15 Thread Denis Koroskin
On Wed, 16 Mar 2011 02:40:32 +0300, nedbrek wrote: Hello, I have some wrappers for C functions which I am exporting to D. For D1, I can just use char*. For D2, I get compiler errors when I try to assign string constants to my char* variables. It seems the best way is to make them immutabl

Re: [improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread Andrej Mitrovic
On 3/16/11, bearophile wrote: > I meant to suggest you to use the > std.algorithm sort instead of the deprecated built-in one, because the > built-in one is slow and it has bad bugs, like this one I've found: > http://d.puremagic.com/issues/show_bug.cgi?id=2819 Thanks, I didn't know about the bug

Re: [improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread bearophile
Andrej Mitrovic: > Correction: DMD complains about having parentheses, in fact it's an error: > ngparser.d(28): Error: undefined identifier module ngparser.sort > > So I've had to remove them. And again that's that uninformative error > message which I don't like. Sorry, this time the uninformat

Best practice for strings across D1 and D2

2011-03-15 Thread nedbrek
Hello, I have some wrappers for C functions which I am exporting to D. For D1, I can just use char*. For D2, I get compiler errors when I try to assign string constants to my char* variables. It seems the best way is to make them immutable(char). 1) If I make the functions take immutable(ch

Re: [improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread Andrej Mitrovic
On 3/15/11, Andrej Mitrovic wrote: > >> >> I suggest to replace this: >> sortedKeys.sort; >> >> With: >> sortedKeys.sort(); >> > > Yes, I prefer it that way too. Correction: DMD complains about having parentheses, in fact it's an error: ngparser.d(28): Error: undefined identifier module ngparser.

Re: [improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread Andrej Mitrovic
On 3/15/11, bearophile wrote: > Andrej Mitrovic: > >> I've also implemented an `allSatisfy` function which works on runtime >> arguments. There's a similar function in std.typetuple, but its only >> useful for compile-time arguments. There's probably a similar method >> someplace in std.algorithm,

Re: [improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread bearophile
Andrej Mitrovic: > I've also implemented an `allSatisfy` function which works on runtime > arguments. There's a similar function in std.typetuple, but its only useful > for compile-time arguments. There's probably a similar method someplace in > std.algorithm, but I was too lazy to check. I tho

[improve-it] Parsing NG archive and sorting by post-count

2011-03-15 Thread Andrej Mitrovic
I thought about making a kind of code-golf contest (stackoverflow usually has these contests). Only I would focus on improving each others code. So here's my idea of the day: Parse the newsgroup archive files from http://www.digitalmars.com/NewsGroup.html, and for each .html file output another

Re: Deducing types for function templates

2011-03-15 Thread Michel Fortin
On 2011-03-15 13:20:30 -0400, "Simen kjaeraas" said: On Tue, 15 Mar 2011 17:36:04 +0100, Michel Fortin wrote: On 2011-03-15 10:42:46 -0400, Magnus Lie Hetland said: I've got a function template along these lines: Foo!T foo(T)(T[] bar, real function(T,T) baz) { ... } The main reason

Re: Deducing types for function templates

2011-03-15 Thread Simen kjaeraas
On Tue, 15 Mar 2011 17:36:04 +0100, Michel Fortin wrote: On 2011-03-15 10:42:46 -0400, Magnus Lie Hetland said: I've got a function template along these lines: Foo!T foo(T)(T[] bar, real function(T,T) baz) { ... } The main reason I'm using this is that it seems necessary to use a f

Re: Deducing types for function templates

2011-03-15 Thread Michel Fortin
On 2011-03-15 10:42:46 -0400, Magnus Lie Hetland said: I've got a function template along these lines: Foo!T foo(T)(T[] bar, real function(T,T) baz) { ... } The main reason I'm using this is that it seems necessary to use a function, rather than a type (such as Foo), if you want the compil

Deducing types for function templates

2011-03-15 Thread Magnus Lie Hetland
I've got a function template along these lines: Foo!T foo(T)(T[] bar, real function(T,T) baz) { ... } The main reason I'm using this is that it seems necessary to use a function, rather than a type (such as Foo), if you want the compiler to deduce the compile-time parameters. (Right?) Now .