[Haskell-cafe] Specify array or list size?
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Sat May 7 14:32:46 EDT 2005
Antti-Juhani Kaijanaho <antti-juhani at kaijanaho.info> writes:
>> > As far as I know, the last programming language that included
>> > arrays' sizes in their types was Standard Pascal,
>>
>> There have been many such languages since Standard Pascal. For
>> example C, C++, C#, Java, Ada, VHDL, and NU-Prolog.
>
> C, C++ and Java do not belong to that list. I can't speak about the
> others, not being very familiar with them.
Java and C# don't belong to that list, but C and C++ do.
I don't know about others.
> In C and C++, the declaration int n[50]; introduces an array variable
> with size 50 having the type "array of int". The size is *not* part of
> the type.
No, it introduces a variable of type "array of 50 ints", which can be
converted to "pointer to int".
It matters when you make a pointer of such arrays, an array of such
arrays, or sizeof such array. In C++ the size can be matched by
template parameter, and you can have separate overloadings for
separate array sizes.
--
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
More information about the Haskell-Cafe
mailing list