-- This example has three compilation units : -- The generic package specification for GENSUMPKG -- The package body for GENSUMPKG -- The test procedure that instantiates GENSUMPKG with -- generic actual parameters INTEGER and MY_ARRAY -- -- generic type ELEMENT is private ; type KEY_1 is array ( INTEGER range <> ) of ELEMENT ; with function "+" ( U , V : ELEMENT ) return ELEMENT is <> ; package GENSUMPKG is procedure SUM ( A : in out KEY_1 ) ; end GENSUMPKG ; -- end of first compilation unit package body GENSUMPKG is procedure SUM ( A : in out KEY_1 ) is TOTAL : ELEMENT := A ( A'FIRST ) ; -- no numbers allowed begin for I in A'FIRST + 1 .. A'LAST loop TOTAL := TOTAL + A ( I ) ; end loop ; A ( A'FIRST ) := TOTAL ; end SUM ; end GENSUMPKG ; -- end of second compilation unit with TEXT_IO ; use TEXT_IO ; with GENSUMPKG ; procedure TEST_GENSUMPKG is type MY_ARRAY is array ( INTEGER range <> ) of FLOAT ; STUFF : MY_ARRAY ( 1 .. 3 ) := ( 1.0 , 2.0 , 3.0 ) ; package FLT_IO is new FLOAT_IO ( FLOAT ) ; use FLT_IO ; -- This is the generic instantiation of the package above package MY_SUM is new GENSUMPKG ( ELEMENT => FLOAT , KEY_1 => MY_ARRAY ) ; use MY_SUM ; -- optional, could also write MY_SUM.SUM below begin PUT_LINE ( " GENERIC SUM PACKAGE " ) ; SUM ( STUFF ) ; -- call procedure in instantiated package PUT ( STUFF( 1 )) ; PUT_LINE ( " = SUM " ) ; end TEST_GENSUMPKG ;