Figure 2.
Distinct types.
------------------------------------------------------------
-- Each declared type is distinct, even if they have the
-- same name and definition as another integer type and are
-- in the same file.
-- In the example below, the two packages X and Y, and the
-- procedure P, are in a file called XYP.ada.
-- XYP.ada
package X is
type Whole_numbers is range -32768..32767;
procedure Fool_With(N : in out Whole_numbers);
end X;
package Y is
type Whole_numbers is range -32768..32767;
procedure Produce(Z : out Whole_numbers);
end Y;
with X, Y; use X, Y;
procedure P is
type Whole_numbers is range -32768..32767;
W : Whole_numbers;
begin
Produce(W); -- this is line 28
Fool_With(W); -- this is line 29
end P;
----------------------------------------------------
When you compile the file XYP.ada above, here's what
you get:
Meridian AdaVantage(tm) Compiler [v1.5 Apr 3, 1987] Target
8086
Package x added to library.
Package y added to library.
"XYP.ada", line 28: <> identifier has wrong type "w"
"XYP.ada", line 29: <> identifier has wrong type "w"
31 lines compiled.
2 errors detected.