Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 26, 2002 Passing multidimensional dynamic arrays to functions? | ||||
---|---|---|---|---|
| ||||
I have not yet tried D, but I like what I see. There is one essential feature that is missing from many languages, and I'm not sure whether or how this is done in D. That is, passing multidimensional dynamic arrays to functions. This is essential if the array size is not known at compile time. It is also essential to be able to determine the array size within the function, and for the compiler to be able to do array bounds checking. Is this implemented? Of course, this is not possible in C++. Previously, one had to use Fortran, certain dialects of Pascal and Oberon, or Java to get this feature. I especially like the Java way of doing it. |
July 26, 2002 Re: Passing multidimensional dynamic arrays to functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rex Couture | "Rex Couture" <auser@levee.wustl.edu> wrote in message news:ahrp51$2m2q$1@digitaldaemon.com... > I have not yet tried D, but I like what I see. There is one essential feature > that is missing from many languages, and I'm not sure whether or how this is > done in D. That is, passing multidimensional dynamic arrays to functions. This is essential if the array size is not known at compile time. It is also > essential to be able to determine the array size within the function, and for > the compiler to be able to do array bounds checking. Is this implemented? Yes. |
July 26, 2002 Re: Passing multidimensional dynamic arrays to functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rex Couture | On Fri, 26 Jul 2002 15:16:49 +0000 (UTC) Rex Couture <auser@levee.wustl.edu> wrote:
> I have not yet tried D, but I like what I see. There is one essential feature that is missing from many languages, and I'm not sure whether or how this is done in D. That is, passing multidimensional dynamic arrays to functions.
A sample piece of code:
void print(double[][] matrix)
{
for (int i = 0; i < matrix.length; i++)
{
for (int j = 0; j < matrix[i].length; j++)
printf("%10g", matrix[i][j]);
}
printf("\n");
}
|
July 26, 2002 Re: Passing multidimensional dynamic arrays to functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Thanks, Pavel and Walter. |
Copyright © 1999-2021 by the D Language Foundation