On Saturday, 30 June 2012 at 18:32:09 UTC, Jonathan M Davis wrote:
In D, static arrays are always fixed in size, and that size
must be known at
compile time, whereas dynamic arrays are never fixed in size
(unless they're
immutable), and the size doesn't need to be known at compile
time. There is no
way to have a static array whose size isn't known at compile
time, which is
what you'd need for what you're trying to do.
Thanks for the answer. It makes sense, yet when used to
multidimensional arrays as implemented in Java it takes some time
to wrap your head around this.
I believe that the only way to do it would be to create a
struct which wrapped
a single dimensional, dynamic array, and then overloaded
opIndex appropriately
This is a very good suggestion, I hadn't thought of this
possibility, this way I can get my beloved "matrix[x][y];"
instead of something like "matrix.get(x, y);".