The Ada Program: cnst.adb

  1 -- cnst.adb:  small program showing constant arrays can't be changed
  2 
  3 procedure Cnst is
  4 
  5    type T is array (1..2) of Integer;
  6 
  7    A : constant T := T'(T'Range=>34);
  8    B : T;
  9 
 10 begin
 11 
 12    B := A;
 13    B(2) := A(2);
 14 
 15    -- Can't change "A" or its components; i.e,
 16    --
 17    --   A := B;
 18    --   A(2) := B(2);
 19    --
 20    -- are illegal
 21 
 22 end Cnst;