Re: Reading stdin in Windows 7

2010-09-02 Thread Joel Christensen
On 01-Sep-10 12:54 PM, Andrej Mitrovic wrote: Oooops, I meant: std.stdio.StdioException: Bad file descriptor type test.d | test.exe works, but waits on exit: test.exe | type test.d works fine: test.exe< test.d I think I get the same as you. Have to put Ctrl+C (or some thing) to get out, for

Re: I don't understand a const

2010-09-02 Thread Simen kjaeraas
bearophile wrote: This program doesn't compile, dmd prints the errors: test.d(4): Error: template test.foo(T) does not match any function template declaration test.d(4): Error: template test.foo(T) cannot deduce template function from argument types !()(const(int),int) test.d(9): Error: te

Re: I don't understand a const

2010-09-02 Thread Michal Minich
On Wed, 01 Sep 2010 22:22:22 -0400, bearophile wrote: > This program doesn't compile, dmd prints the errors: test.d(4): Error: > template test.foo(T) does not match any function template declaration > test.d(4): Error: template test.foo(T) cannot deduce template function > from argument types !()(

rebindable static array

2010-09-02 Thread Michal Minich
// Original question by Peter Alexander is at http://stackoverflow.com/ questions/3627023/how-do-you-initialise-an-array-of-const-values-in-d2 to summarize consider this code: const(int)[2] a; const int [2] b; const(int)[] c; const int [] d; void main () { a = [1, 2]; // Error: slice a[] is no

Re: rebindable static array

2010-09-02 Thread Simen kjaeraas
Michal Minich wrote: from high level point of view, there is difference in const(int)[2] and const (int [2]). One would expect that it is possible to rebind b. From low level/implementation point - there seems to be no difference because a and b are value types - there is not indirection. Poss

Re: I don't understand a const

2010-09-02 Thread Brad Roberts
On 9/2/2010 5:59 AM, Simen kjaeraas wrote: > bearophile wrote: > >> This program doesn't compile, dmd prints the errors: >> test.d(4): Error: template test.foo(T) does not match any function template >> declaration >> test.d(4): Error: template test.foo(T) cannot deduce template function from >>

Re: I don't understand a const

2010-09-02 Thread Michal Minich
On Thu, 02 Sep 2010 11:11:52 -0700, Brad Roberts wrote: > On 9/2/2010 5:59 AM, Simen kjaeraas wrote: >> void bar(T)(const T x, out T y) {} >> >> void main() { >> const int s1; >> int s2; >> bar(s1, s2); >> } >> >> It seems DMD is confused by const(int) being such a nice fit for the >

Re: I don't understand a const

2010-09-02 Thread bearophile
Brad Roberts: > http://d.puremagic.com/issues/show_bug.cgi?id=4594 Thanks for all the answers. Bye, bearophile

SO rotate question

2010-09-02 Thread simendsjo
http://stackoverflow.com/questions/2553522/interview-question-check-if-one-string-is-a-rotation-of-other-string I created a solution, but I don't want D to look bad, so I won't post it. It's a bit for loop heavy... At least it's shorter than the c example, but I don't know about speed or readab

Re: SO rotate question

2010-09-02 Thread bearophile
simendsjo: > Suggestions for D-ifying the code is welcome. Your unit tests are not good enough, they miss some important corner cases. This my first version in D2: import std.string: indexOf; /// return True if s1 is a rotated version of s2 bool isRotated(T)(T[] s1, T[] s2) { return (s1.leng

Re: SO rotate question

2010-09-02 Thread bearophile
> bool isRotated(T)(T[] s1, T[] s2) { A better signature for the same function, I need to train myself to use pure and const more often :-) pure bool isRotated(T)(const T[] s1, const T[] s2) { Bye, bearophile

Re: SO rotate question

2010-09-02 Thread simendsjo
On 02.09.2010 22:24, bearophile wrote: simendsjo: Suggestions for D-ifying the code is welcome. Your unit tests are not good enough, they miss some important corner cases. This my first version in D2: import std.string: indexOf; /// return True if s1 is a rotated version of s2 bool isRotated

Re: SO rotate question

2010-09-02 Thread Pelle
On 09/02/2010 10:24 PM, bearophile wrote: simendsjo: Suggestions for D-ifying the code is welcome. Your unit tests are not good enough, they miss some important corner cases. This my first version in D2: import std.string: indexOf; /// return True if s1 is a rotated version of s2 bool isRota