AI22-0039-1

!standard 8.3(26/2)                                        22-02-04  AI22-0039-1/01

!class presentation 22-02-04

!status work item 22-02-04

!status received 21-05-20

!priority Low

!difficulty Easy

!subject Clarify 8.3(26/2)

!summary

The wording of 8.3(26/2) is clarified.

!issue

[WG 9 comment #150] 8.3(26/2) starts by stating several rules for various things, and then says "These rules also apply to dispatching operators declared in the visible part of an instance of a generic unit". The part "these rules" is confusing, because some of the rules stated earlier in the

paragraph apply to type extensions or to context clauses, neither of which seems relevant to declarations of dispatching operations. Should this be clarified? (Yes.)

!recommendation

(See Summary.)

!wording

Modify 8.3(26/2):

A nonoverridable declaration is illegal if there is a homograph occurring immediately within the same declarative region that is visible at the place of the declaration, and is not hidden from all visibility by the non-overridable declaration. In addition, a type extension is illegal if somewhere within its immediate scope it has two visible components with the same name. Similarly, the context_clause for a compilation unit is illegal if it mentions (in a with_clause) some library unit, and there is a homograph of the library unit that is visible at the place of the compilation unit, and the homograph and the mentioned library unit are both declared immediately within the same declarative region. These rules {that apply to subprograms }also apply to  dispatching operations declared in the visible part of an instance of a generic unit. However, they do not apply to other overloadable declarations in an instance; such declarations may have type conformant profiles in the instance, so long as the corresponding declarations in the generic were not  type conformant.

Add after AARM 8.3(26.k):

AARM Ramification: The type extension component rule obviously does not  apply to dispatching operations in an instance. However, the context clause rule could apply, as a compilation unit can be a subprogram.

[Editor's note: I'm unsure that the wording added to the normative wording

actually helps anything. Perhaps we should just add an AARM note like the one

given??]

!discussion

The last two sentences of 8.3(26/2) are original Ada 95 wording. At that time, the rule about type extension components did not exist, and the context clause rule was only about subunits. In that case, it is fairly clear how both of these rules could apply in the generic instance case (since a subunit can be a completion of a dispatching operation).

Later bug fixes broadened the subunit rule to any compilation unit, and the type extension rule was added. After those changes, the connection to the later sentences was lost.

!corrigendum 8.3(26/2)

@drepl

A nonoverridable declaration is illegal if there is a homograph occurring

immediately within the same declarative region that is visible at the place of

the declaration, and is not hidden from all visibility by the non-overridable

declaration. In addition, a type extension is illegal if somewhere within its

immediate scope it has two visible components with the same name. Similarly,

the @fa{context_clause} for a compilation unit is illegal if it mentions (in a

@fa{with_clause}) some library unit, and there is a homograph of the library

unit that is visible at the place of the compilation unit, and the homograph

and the mentioned library unit are both declared immediately within the same

declarative region. These rules also apply to dispatching operations declared

in the visible part of an instance of a generic unit. However, they do not

apply to other overloadable declarations in an instance; such declarations may

have type conformant profiles in the instance, so long as the corresponding

declarations in the generic were not type conformant.

@dby

A nonoverridable declaration is illegal if there is a homograph occurring

immediately within the same declarative region that is visible at the place of

the declaration, and is not hidden from all visibility by the non-overridable

declaration. In addition, a type extension is illegal if somewhere within its

immediate scope it has two visible components with the same name. Similarly,

the @fa{context_clause} for a compilation unit is illegal if it mentions (in a

@fa{with_clause}) some library unit, and there is a homograph of the library

unit that is visible at the place of the compilation unit, and the homograph

and the mentioned library unit are both declared immediately within the same

declarative region. These rules that apply to subprograms also apply to

dispatching operations declared in the visible part of an instance of a

generic unit. However, they do not apply to other overloadable declarations

in an instance; such declarations may have type conformant profiles in the

instance, so long as the corresponding declarations in the generic were not

type conformant.

!ACATS test

No tests are needed for presentation changes.

!appendix

From: Niklas Holsti

WG 9 Review issue #150 - May 20, 2021

[Comment on 8.3(26/2).]

The paragraph starts by stating several rules for various things, and then

says "These rules also apply to dispatching operators declared in the visible

part of an instance of a generic unit". The part "these rules" is confusing,

because some of the rules stated earlier in the paragraph apply to type

extensions or to context clauses, neither of which seems relevant to

declarations of dispatching operations. It seems that only the first rule

stated in this paragraph, about non-overridable declarations, can apply to

declarations of dispatching operations. It would be clearer to separate the

rules for type extensions and context clauses into their own paragraphs (and,

in the annotated RM, distribute the annotations accordingly).

On second thought, perhaps the point about the dispatching operations is that

such an operation could be the "homograph of the library unit" that is

involved in the rule for context clauses. But at least the rule about type

extensions seems irrelevant to dispatching operations.

****************************************************************

From: Randy Brukardt

WG 9 Review issue #150 - May 21, 2021

It's fairly clear from the AARM notes that both the first and third rules

could apply to a dispatching operation (since compilation units can be a

subprogram). And it is harmless (even if confusing) to apply the second rule

in that case (it obviously only applies to types, so it doesn't ever trigger

for a subprogram). As such, there is nothing actually wrong here, and this is

old (Ada 2005) text. Thus this suggestion is out of bounds for this review and

it is marked deferred.

****************************************************************