This is "GENERIC" summary information extracted from ISO 8652:1995 Generic packages, procedures and functions definition instantiation 1. GENERIC LIBRARY UNITS The three structures for a generic library unit are: generic -- *** generic formal part goes here (see below) package NAME is -- typical package specification -- DO NOT duplicate declarations given above in generic formal part end NAME ; package body NAME is -- typical package body begin \__ optional -- package initialization code / exception \__ optional -- exception handlers / end NAME ; -- <-- NAME will be the library unit name "withed" and instantiated generic -- *** generic formal part goes here (see below) procedure NAME(...) ; procedure NAME(...) is -- typical procedure declarations -- DO NOT duplicate declarations given above in generic formal part begin -- typical procedure code exception \__ optional -- exception handlers / end NAME ; -- <-- NAME will be the procedure name "withed" and instantiated generic -- *** generic formal part goes here (see below) function NAME(...) return TYPEX ; function NAME(...) return TYPEX is -- typical function declarations -- DO NOT duplicate declarations given above in generic formal part begin -- typical function code exception \__ optional -- exception handlers / end NAME ; -- <-- NAME will be the function name "withed" and instantiated 2. GENERIC FORMAL PART Listed below are the statements that can occur in the generic formal part. Note: Upon generic instantiation the things denoted FORMAL can be supplied as 1) positional actual generic parameters 2) named actual generic parameters, or 3) not supplied because a default is provided. The same rules apply for parameters in generic instantiation as for procedure calls. The positional order of generic parameters is determined by the sequential order in which the things denoted FORMAL ( a type ) or FORMAL_OBJECT ( an object ) or FORMAL_SUBPROGRAM ( a procedure or function ) occur in the generic formal part. *** generic formal part statements: -- one form of formal generic object parameter FORMAL_OBJECT : SOME_TYPE := default_value ; -- default is optional Note: "SOME_TYPE" can be a language predefined type or a previously defined formal type ( e.g. some FORMAL ) SOME_TYPE may be preceded by "in", "out", or "in out" -- twenty forms of formal generic type parameters type FORMAL is private ; -- class of all nonlimited types type FORMAL is limited private ; -- class of all types type FORMAL is tagged private ; -- class of all nonlimited tagged types type FORMAL is tagged limited private ;-- class of all tagged types type FORMAL is abstract tagged private;-- class of what is says type FORMAL is abstract tagged limited private ; -- class of what it says type FORMAL(...) is private ; -- record type,discriminant provided type FORMAL is (<>) ; -- a discrete type,integer and enum type FORMAL is range <> ; -- an integer type type FORMAL is digits <> ; -- a floating type type FORMAL is mod <> ; -- a modular type type FORMAL is delta <> ; -- a fixed point type type FORMAL is delta <> digits <>; -- a decimal fixed point type type FORMAL is access SOME_TYPE ; -- an access type type FORMAL is access all SOME_TYPE ; -- for aliased access types type FORMAL is access constant SOME ; -- for access to a constant type type FORMAL is new SOME_TYPE ; -- a derived type type FORMAL is new SOME with private ; -- a derived tagged type type FORMAL is access procedure ; -- a procedure type FORMAL is access function return SOME ; -- a function -- two forms of formal generic array type parameters type FORMAL is array (SOME_TYPE range <> ) of SOME_TYPE_2 ; -- unconstrained type FORMAL is array (SOME_DISCRETE_TYPE) of SOME_TYPE_2 ; -- constrained -- three forms of formal generic procedure parameters with procedure FORMAL_PROCEDURE(JUNK_NAME : SOME_TYPE ; ...) ; -- no default with procedure FORMAL_PROCEDURE(JUNK_NAME : SOME_TYPE ; ...) is DEFAULT_NAME ; with procedure FORMAL_PROCEDURE(JUNK_NAME : SOME_TYPE ; ...) is <> ; -- its own name is the default -- three forms of formal generic function parameters with function FORMAL_FUNCTION(JUNK_NAME : SOME_TYPE ; ...) return SOME_TYPE_2 ; -- no default with function FORMAL_FUNCTION(JUNK_NAME : SOME_TYPE ; ...) return SOME_TYPE_2 is DEFAULT_NAME ; with function FORMAL_FUNCTION(JUNK_NAME : SOME_TYPE ;...) return SOME_TYPE_2 is <> ; -- its own name is the default -- Note: FORMAL_SUBPROGRAM is written "+" or ">" for operators -- two forms of formal generic packages with package FORMAL_PACKAGE is new SOME_GENERIC_PACKAGE(ACTUAL_ARGUMENTS); with package FORMAL_PACKAGE is new SOME_GENERIC_PACKAGE(<>); Once instantiated, the above forms with the "FORMAL" and "SOME_TYPE" things replaced by the actual generic parameters are put into the package specification or procedure declarative section or the function declarative section depending on the kind of generic unit. 3. GENERIC INSTANTIATION Remember that the generic library unit must be "withed" but can not have a "use". A generic instantiation can occur any where a declaration can occur. The three forms of generic instantiation are: package YOUR_NAME is new GENERIC_PACKAGE_NAME( ACTUAL_GENERIC_PARAMETERS) ; -- may be followed by " use YOUR_NAME ; " procedure YOUR_NAME is new GENERIC_PROCEDURE_NAME ( ACTUAL_GENERIC_PARAMETERS ) ; -- do not confuse the procedure parameters with the generic parameters ! function YOUR_NAME is new GENERIC_FUNCTION_NAME ( ACTUAL_GENERIC_PARAMETERS ) ; 4. REFERENCES ISO 8652:1995 chapter 12 Barnes chapter 17