The number of parameters is used for overload resolution AI-00463/05 1
89-06-16 ra WA
| !standard 08.07 (19) 89-06-16 AI-00463/05
!class ramification 86-10-02
| !status WG9-approved 89-06-16
!status ARG-approved 88-01-30 (reviewed)
!status ARG-approved 88-10-31 (11-0-0) (pending editorial review)
!status work-item 87-03-20
!status received 86-10-02
!references 83-00811
!topic The number of parameters is used for overload resolution
!summary 88-12-08
Rules that require the number of parameters to be the same are considered in
overload resolution.
!question 88-12-08
Is the number of parameters considered in resolving the name of a subprogram
when the subprogram is not being called? For example, consider:
procedure F (X : INTEGER); -- F1
procedure F (X : INTEGER; Y : INTEGER); -- F2
procedure R (Z : INTEGER) renames F; -- legal? (yes)
Can F in the renaming declaration be resolved to denote F1? 8.7(7-8) say:
When considering possible interpretations of a complete context,
the only rules considered are the syntax rules, the scope and
visibility rules, and the rules of the form described below.
(a) Any rule that requires a name or expression to have a
certain type, or to have the same type as another name or
expression. ...
In the example, F1 and F2 clearly do not have the same number of parameters,
but can this fact be used to resolve F in the renaming declaration? Remember
that in general, overloading resolution does not use all possible
information. For example:
package P is
procedure G (X : out INTEGER);
end P;
package Q is
procedure G (X : in INTEGER);
end Q;
with P, Q; use P, Q;
package R is
procedure W (X : in INTEGER) renames G; -- illegal
end R;
This renaming declaration is illegal because parameter modes are not
The number of parameters is used for overload resolution AI-00463/05 2
89-06-16 ra WA
mentioned in 8.7 as a basis for resolving overloaded subprogram and entry
names, and hence, the use of G in the renaming declaration is ambiguous.
Since the number of parameters is also not mentioned in 8.7's rules, does
this mean that the number of parameters similarly cannot be used to resolve F
in the first example? The note in 8.7(19) says resolution is possible:
Rules that require certain constructs to have the same parameter
and result type profile fall under the category (a); ...
Is this note correct? Are rules that require parameter and result type
profiles to be the same, in particular, those in 8.5(7) and 12.3.6(1, 2),
considered in overload resolution?
!response 88-12-08
8.5(7) says, for a renaming of a subprogram or entry:
The renamed subprogram or entry and the subprogram specification
given in the renaming declaration must have the same parameter
and result type profile (see 6.6).
The definition of a parameter and result type profile is given in 6.6(1):
Two formal parts are said to have the same PARAMETER TYPE PROFILE
if and only if they have the same number of parameters, and at
each parameter position corresponding parameters have the same
base type. A subprogram or entry has the same PARAMETER AND
RESULT TYPE PROFILE as another subprogram or entry if and only if
both have the same parameter type profile, and either both are
functions with the same result base type, or neither of the two
is a function.
The first sentence of 6.6(1) defines matching parameter type profiles in
terms of both the number of parameters and the corresponding parameter types.
This is a single rule and always includes both parts. Otherwise, there would
be no clear correspondence of parameters to compare for matching types. The
portion of the rule requiring types to match allows the entire rule to be
considered in overload resolution via 8.7(8) (rule (a)). From this, it
follows that parameter and result type profiles are considered in overload
resolution, and hence, the number of parameters is considered.