12.7 Formal Packages

From OC Systems Wiki!
Jump to: navigation, search

Formal packages can be used to pass packages to a generic unit. The formal_package_declaration declares that the formal package is an instance of a given generic package. Upon instantiation, the actual package has to be an instance of that generic package.

Syntax

formal_package_declaration ::=
    with package defining_identifier is new generic_package_name  formal_package_actual_part;

 formal_package_actual_part ::=
    (<>) | [generic_actual_part]

Legality Rules

The generic_package_name shall denote a generic package (the template for the formal package); the formal package is an instance of the template.

The actual shall be an instance of the template. If the formal_package_actual_part is (<>), then the actual may be any instance of the template; otherwise, each actual parameter of the actual instance shall match the corresponding actual parameter of the formal package (whether the actual parameter is given explicitly or by default), as follows:

  • For a formal object of mode in the actuals match if they are static expressions with the same value, or if they statically denote the same constant, or if they are both the literal null.
  • For a formal subtype, the actuals match if they denote statically matching subtypes.
  • For other kinds of formals, the actuals match if they statically denote the same entity.

For the purposes of matching, any actual parameter that is the name of a formal object of mode in is replaced by the formal object's actual expression (recursively).

Static Semantics

A formal_package_declaration declares a generic formal package.

The visible part of a formal package includes the first list of basic_declarative_items of the package_specification. In addition, if the formal_package_actual_part is (<>), it also includes the generic_formal_part of the template for the formal package.

Copyright © 1992,1993,1994,1995 Intermetrics, Inc.
Copyright © 2000 The MITRE Corporation, Inc. Ada Reference Manual