Thread overview
Passing multidimensional dynamic arrays to functions?
Jul 26, 2002
Rex Couture
Jul 26, 2002
Walter
Jul 26, 2002
Pavel Minayev
Jul 26, 2002
Rex Couture
July 26, 2002
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
"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
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
Thanks, Pavel and Walter.