code generalization

Saaa empty at needmail.com
Mon Jun 8 18:02:18 PDT 2009


"Christopher Wright" <dhasenan at gmail.com> wrote in message 
news:h0kagg$13so$1 at 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[] for int[][], so you can 
> recursively call the parsing function with A as the type argument rather 
> than U.

I'm sorry, it is still a bit difficult to see as it's all a bit new to me 
but,
depth is the current depth not the depth of the array.
With a[][][] you  can be in 3 depth levels so there need to be as
many cases as the depth of the array.
I probably also need recursion to in stead of the switch create a function
which can set the length of an array at a certain depth :)




More information about the Digitalmars-d-learn mailing list