473,491 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what does 'covariant arrays' mean?

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?

Tydr
Nov 14 '05 #1
4 2832

"Tydr Schnubbis" <na**@fake.yup> a crit dans le message de
news:FM*****************@news4.e.nsc.no...

Hi,
I've read an interview with Brian Kernighan here:
http://www-2.cs.cmu.edu/~mihaib/kern...iew/index.html.
Interesting !
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).'
You did'nt quote all the text:

The interviewer asks: " I have a question about research in language design.
It's interesting for instance that Java is very much hyped and the community
is split among the merits and flaws of the language. The language has indeed
acquired some nice features proposed by researchers in the area (like
garabage collection), 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?


It was about Java, not about C :). There are no covariant arrays in C.

Regis
Nov 14 '05 #2
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
Nov 14 '05 #3
"Tydr Schnubbis" <na**@fake.yup> wrote in message
news:FM*****************@news4.e.nsc.no...
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?

Tydr


A covariant array is an array data structure where the elements can be of
differing type. I think it could be implemented indirectly through an array
of pointers in C (although this isn't the same really), or more far-fetched,
as an array of unions with a lookup array array that identifies the type of
each entry in the original array. If viewed as a weakness would it not just
be for the fact you need to code it yourself? Same type arrays are more
efficient for access since it's a scaled jump table of entries, when the
data types start changing you lose efficient register indirect access.

--
Raymond.
Nov 14 '05 #4
It was about Java, not about C :). There are no covariant arrays in C.


Right you are. Sorry about that little blunder, I shall apply the
appropriate punishment to myself.

Tydr
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2176
by: Graham | last post by:
On page 89 of Stroustrup's book "The C++ Programming Language" 3rd Ed. He says that multidimensional arrays are best avoided outside low-level code. What precisely does he mean by low-level...
13
4233
by: Stephen Walch | last post by:
Error C2392 is hitting me hard! I have a managed C++ library that implements a bunch of fixed interfaces. For example, one interface is: public abstract interface IDbCommand { public...
13
4996
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
2
1466
by: Mike | last post by:
I keep running into the scenario below over and over again. Currently I get around not having covariant return types by using an interface and explicit property definitions which works to some...
16
3174
by: Bob Hairgrove | last post by:
Consider the classic clone() function: class A { public: virtual ~A() {} virtual A* clone() const = 0; }; class B : public A { public:
669
25375
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
8
2161
by: Alex Vinokur | last post by:
Here is a code from http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8 -------------------------------------- class Shape { public: virtual ~Shape() { } // A...
3
4528
by: kikazaru | last post by:
Is it possible to return covariant types for virtual methods inherited from a base class using virtual inheritance? I've constructed an example below, which has the following structure: Shape...
4
1115
by: Jon | last post by:
struct B2; struct B1 { virtual B2* get2() = 0; }; struct B2 { virtual B1* get1() = 0; };
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.