views:

47

answers:

2

I have here a question: 6. Ada supports named equivalence. Given the declaration:

A: array(1..10) of integer;
B: array(1..10) of integer;

Are A and B compatible? What if we declare this as

A, B: array(1..10) of integer;

Are A and B compatible? Yet another way of declaring this is

Type array10 is array(1..10) of integer;
A, B: array 10;

Are A and B compatible? If Ada supports structural equivalence, what will be the answer to the three questions above?

+2  A: 

This frequently asked question is meant to highlight the difference between name equivalence and structural equivalence in a strongly typed language such as Ada. For reference, see Ada Programming/Type System and Rationale for the Design of the Ada® Programming Language.

trashgod
That Type System link is just about perfect for the question. If Ivy's problem is that the supporting material for her question was confusing (or not available somehow), that might help.
T.E.D.
+1  A: 

We can answer Ada questions fairly well. However, this appears to be a chapter material comprehension question masquerading as an Ada question. In particular, a lot depends on how exactly they defined "compatible", "named equivalence", and "structural equivalence". (Although the latter two do have a fairly well-defined meaning) One part of the question is even theoretical based on a facility that Ada does not have. Without that context, it would be tough to answer.

The answer is to be found not in the Ada LRM anywhere, but in the text of your book. Read the chapter, and you should become enlightened.

T.E.D.