-- Chapter 22 - Program 8 with Ada.Text_IO, Ada.Finalization; use Ada.Text_IO, Ada.Finalization; package Component is type WIDGET is new CONTROLLED with record Size : INTEGER; Number : INTEGER; end record; procedure Initialize(Item : in out WIDGET); procedure Adjust(Item : in out WIDGET); procedure Finalize(Item : in out WIDGET); end Component; package body Component is procedure Initialize(Item : in out WIDGET) is begin Put_Line(" This is from Initialize"); end Initialize; procedure Adjust(Item : in out WIDGET) is begin Put_Line(" This is from Adjust"); end Adjust; procedure Finalize(Item : in out WIDGET) is begin Put_Line(" This is from Finalize"); end Finalize; end Component; with Ada.Text_IO, Component; use Ada.Text_IO, Component; procedure Control is Paper : WIDGET; Pencil : WIDGET; begin Put_Line("Beginning this simple program"); Paper.Size := 11; Paper.Number := 25; Put_Line("Paper record filled with data"); Pencil := Paper; Put_Line("Paper copied to Pencil"); Paper := Pencil; Put_Line("Pencil copied to Paper"); end Control; -- Result of execution -- -- This is from Initialize -- This is from Initialize -- Beginning this simple program -- Paper record filled with data -- This is from Finalize -- This is from Adjust -- Paper copied to Pencil -- This is from Finalize -- This is from Adjust -- Pencil copied to Paper -- This is from Finalize -- This is from Finalize