www.digitalmars.com         C & C++   DMDScript  

D - Passing multidimensional dynamic arrays to functions?

reply Rex Couture <auser levee.wustl.edu> writes:
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.
Jul 26 2002
next sibling parent "Walter" <walter digitalmars.com> writes:
"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

 that is missing from many languages, and I'm not sure whether or how this

 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

 essential to be able to determine the array size within the function, and

 the compiler to be able to do array bounds checking.  Is this implemented?

Yes.
Jul 26 2002
prev sibling parent reply Pavel Minayev <evilone omen.ru> writes:
On Fri=2C 26 Jul 2002 15=3A16=3A49 +0000 =28UTC=29 Rex Couture
=3Causer=40levee=2Ewustl=2Eedu=3E 
wrote=3A

=3E I have not yet tried D=2C but I like what I see=2E  There is one essential
feature
=3E that is missing from many languages=2C and I'm not sure whether or how this
is
=3E done in D=2E  That is=2C passing multidimensional dynamic arrays to
functions=2E

A sample piece of code=3A

=09void print=28double=5B=5D=5B=5D matrix=29
=09{
=09=09for =28int i =3D 0=3B i =3C matrix=2Elength=3B i++=29
=09=09{
=09=09=09for =28int j =3D 0=3B j =3C matrix=5Bi=5D=2Elength=3B j++=29
=09=09=09=09printf=28=22%10g=22=2C matrix=5Bi=5D=5Bj=5D=29=3B
=09=09}
=09=09printf=28=22=5Cn=22=29=3B
=09}
Jul 26 2002
parent Rex Couture <Rex_member pathlink.com> writes:
Thanks, Pavel and Walter.
Jul 26 2002