Tydr Schnubbis <na**@fake.yup> writes:
I've read an interview with Brian Kernighan here:
http://www-2.cs.cmu.edu/~mihaib/kern...iew/index.html.
The interviewer asks him, among other things, about the weaknesses of C.
This is from one of the questions:
'...but also the researchers point some of its weaknesses (like the
arrays which are covariant and they shouldn't be).'
There's no explaination of what a covariant array is. I've found some
explainations of what this means in a Java context, but can anyone
explain to me what this means in the C language, and why this is
considered a weakness?
C doesn't have covariant arrays, because C doesn't have
covariance. Covariance and its sister concept, contravariance,
apply only (as far as I know) to data types arranged in a
hierarchy, as is most often seen in inheritance within
object-oriented type systems. C doesn't have any such hierarchy
of types, so the concept of covariance doesn't arise. C++ and
Java do have inheritance hierarchies and thus questions about
covariance become interesting. In particular, C++ does not
support covariant arrays, but Java does.
--
"Some programming practices beg for errors;
this one is like calling an 800 number
and having errors delivered to your door."
--Steve McConnell