Re: How many people here use stackoverflow.com?

2009-05-24 Thread Tim Matthews
On Sun, 24 May 2009 06:45:51 +1200, Bill Baxter wbax...@gmail.com wrote: Yeh, denied because search is really hard. So they cant just insert an if statement on the line before to check for exact match before trying the search?

Template limits in D2

2009-05-24 Thread bearophile
I am trying to create a non-dynamic array at compile time, so I have written this test code: int sumSqrt(int n) { int result = 0; while (n) { int digit = n % 10; n /= 10; result += digit * digit; } return result; } template GenSquares(int n) { static

Re: Template limits in D2

2009-05-24 Thread Lutger
bearophile wrote: ... The second problem is that compile-time functions are nicer, so I'd like to not use templates when possible. But the following code doesn't work at compile time, can you tell me why? (I have had to use a not nice temporary struct to return the static array)

Re: Template limits in D2

2009-05-24 Thread Ary Borenszweig
Lutger escribió: bearophile wrote: ... The second problem is that compile-time functions are nicer, so I'd like to not use templates when possible. But the following code doesn't work at compile time, can you tell me why? (I have had to use a not nice temporary struct to return the static

Re: Template limits in D2

2009-05-24 Thread Ary Borenszweig
Ary Borenszweig escribió: Lutger escribió: bearophile wrote: ... The second problem is that compile-time functions are nicer, so I'd like to not use templates when possible. But the following code doesn't work at compile time, can you tell me why? (I have had to use a not nice temporary

Re: Template limits in D2

2009-05-24 Thread BCS
Hello Ary, BTW, I had to debug inside Descent's code to find this. If I debug it using the debugger I'm programming, I can see it stops the execution right at the s.a[i] = m; line, without saying why (DMD doesn't say why). It's not much, but I think it's better than Can't evaluate at

Re: Template limits in D2

2009-05-24 Thread Lutger
Ary Borenszweig wrote: ... BTW, I had to debug inside Descent's code to find this. If I debug it using the debugger I'm programming, I can see it stops the execution right at the s.a[i] = m; line, without saying why (DMD doesn't say why). It's not much, but I think it's better than Can't

Re: Applying const to an object but not the container (D 2.0)

2009-05-24 Thread div0
Burton Radons wrote: I'm writing an XML class. There are two tests for this class, isAncestorOf and isDescendantOf, that are implemented in terms of one another. They're both const, and look like this: class Node { Node parentNode; /// ... /// Return whether this is

Why do I get stack overflow?

2009-05-24 Thread Ary Borenszweig
When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)(); return X * temp; } } const someVar = fact!(0)(); ---

Re: Why do I get stack overflow?

2009-05-24 Thread Christopher Wright
Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)(); return X * temp; } } const someVar = fact!(0)(); --- Like

Re: Why do I get stack overflow?

2009-05-24 Thread Moritz Warning
On Sun, 24 May 2009 20:49:53 -0300, Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)();

Re: Why do I get stack overflow?

2009-05-24 Thread Ary Borenszweig
Moritz Warning escribió: On Sun, 24 May 2009 20:49:53 -0300, Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X