Hamilton Richards <[EMAIL PROTECTED]> writes:

> That's not the case in C, C++, Java, or Ada. In C and C++, for
> example, given two arrays
>
>       int X[50];
>       int Y[100];
>
> and a function declared as
>
>       void P( int a[] )
>
> then these calls
>
>       P( X )
>       P( Y )
>
> are both valid, because the sizes of X and Y are not part of their type.

But here you don't pass the array but a pointer to its first element.
You can even call P(&x) where x is an int, not an array at all.

Consider this:

int X[50];
int Y[100];
void P(int (&a)[50]) {}
int main() {
   P(X); // valid
   P(Y); // invalid
}

> In C and C++, there's not even any way for a function to discover
> the size of an array argument.

template<int N>
int size(int (&a)[N]) {
    return N;
}

-- 
   __("<         Marcin Kowalczyk
   \__/       [EMAIL PROTECTED]
    ^^     http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to