Re: code generalization

2009-06-08 Thread Saaa
meant this: which of course also fails, but I hope you get the jist void setLength (T)( ref T array, int depth , int index[]) { if(depth > 0) { depth--; setLength (&array[index[0]], depth, index[1..$]); } else { if(array.length < index[0]) array.length = array.length * 2; }

Re: code generalization

2009-06-08 Thread Saaa
"Christopher Wright" wrote in message news:h0kagg$13s...@digitalmars.com... > Saaa wrote: >> I just finished my array parser but I can't support just any depth >> because each depth needs its own code the way I am doing it now :( > > Recursion? > static if (is (U A : A[])) will give you int[] f

Re: code generalization

2009-06-08 Thread Saaa
"Christopher Wright" wrote in message news:h0kagg$13s...@digitalmars.com... > Saaa wrote: >> I just finished my array parser but I can't support just any depth >> because each depth needs its own code the way I am doing it now :( > > Recursion? > static if (is (U A : A[])) will give you int[] f

Re: code generalization

2009-06-08 Thread Christopher Wright
Saaa wrote: I just finished my array parser but I can't support just any depth because each depth needs its own code the way I am doing it now :( Recursion? static if (is (U A : A[])) will give you int[] for int[][], so you can recursively call the parsing function with A as the type argument

code generalization

2009-06-08 Thread Saaa
I just finished my array parser but I can't support just any depth because each depth needs its own code the way I am doing it now :( Also, as you can see, I am using a doubling strategy to minimize the amount of allocations (strating with 4). Is this still a good strategy with D having a GC? .