AI22-0039-1

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

!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 operations 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. {This rule also applies to dispatching operations declared in the visible part of an instance of a generic unit. However, it does 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.

}[In addition, a]{A} type extension is illegal if somewhere within its immediate scope it has two visible components with the same name. [Similarly, the]{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.  [a][b][c][d][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.]

!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. This rule also applies to dispatching operations declared in the visible part of an instance of a generic unit. However, it does 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.

A type extension is illegal if somewhere within its immediate scope it has two visible components with the same name. 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.

!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.

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

[a]Might be better: "The rules given above that apply to subprograms ..."

[b]Yes, but do we need it? I was unable to convince myself that the context clause rule could ever trigger for a dispatching operation. If "these rules" is really only one rule, rearranging the text would be better. I think that was the reason this was given to you as homework.

[c]Expanding a bit: A context clause can mention a subprogram, but a library unit cannot be a dispatching operation. A stub could be a dispatching operation, but "separate" is NOT part of a context clause, so the rule doesn't apply there anyway (and wouldn't the stub be illegal if there was a problem?). So if only the first rule is really involved with "these rules", then this sentence should just follow the first sentence with "this rule also applies...". Right?

[d]Agreed.  I have made that change, and have suggested a new paragraph for the following sentences.