with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure tryRecords1 is
type Pair is record -- A new type
x: Integer; -- Fields
y: Integer;
end record;
procedure putPair(p: Pair) is
begin
put(p.x); -- Access fields with dot notation
put(p.y);
new_line;
end putPair;
p1: Pair; -- Declare AND allocate!
p2: Pair; -- Not initialized
begin
p1.x := 1;
p1.y := 2;
putPair(p1);
put(p1.x);
new_line;
p2.x := p1.x;
p2.y := p1.y;
putPair(p2);
-- positional aggregate assignment
p1 := (3, 4);
putPair(p1);
-- keyword aggregate assignment
p2 := (y => 6, others => 5);
putPair(p2);
-- Assignment of all fields
p1 := p2;
putPair(p1);
end tryRecords1;
-- OUTPUT
1 2
1
1 2
3 4
5 6
5 6