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!(

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 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 Mor

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: 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 whethe

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

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 compile-

d2 shared delegate problem

2009-05-24 Thread AxelS
Hello everybody, directly to my problem: In class A I got a static array of delegates... class A{ private static alias void delegate() EventHandler; public static EventHandler[] MyEvent; static void Foo() { foreach(eh; MyEvent) eh(); } } ...and when I call Foo() from another Thread like... i

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 str

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 arr

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) > >

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 if