-- Demonstrates that Ada has value semantics
-- The entire array is treated as a value
-- No refererences are involved
with ada.text_io; use ada.text_io;
procedure array_compare2 is
type My_Array_T is array(Natural range <>) of Integer;
a, b: My_Array_T(1 .. 5) := (others => 1);
begin
if a = b then put_line("Same"); else put_line("Diff"); end if;
a := b;
if a = b then put_line("Same"); else put_line("Diff"); end if;
a(1) := 99;
if a = b then put_line("Same"); else put_line("Diff"); end if;
put_line(a(1)'img);
put_line(b(1)'img);
end array_compare2;
-- Output below (what do you predict?):
-- Same
-- Same
-- Diff
-- 99
-- 1