AI22-0098-1

!standard 4.3.5(61/5)                                    24-04-18  AI22-0098-1/03

!standard 4.3.5(63/5)

!standard 4.5.2(9.8/6)

!standard 7.6.1(12/2)

!standard 10.2.1(18/6)

!class presentation 24-03-04

!status Corrigendum 1-2022  24-03-04

!status work item 24-03-04

!status received 24-03-04

!priority Low

!difficulty Easy

!subject More presentation fixes

!summary

Additional presentation improvements to the RM.

!issue

(1) 4.5.2(9.8/6) ends with the standard generic boilerplate in the singular form: “This rule applies also ...”. But this paragraph now has three sentences; each of the sentences describes a different prohibition. Should the boilerplate be given in the plural form? (Yes.)

(2) 10.2.1(18/3) was broken into bullets by AI22-0023-1 to improve its readability. But when that was done, the last sentence of 10.2.1(18/3) was omitted. Should this sentence still be in the RM? (Yes.)

(3) AI22-0062-1 adds a new paragraph about a specific case of assignment. The AI puts the new paragraph after 7.6.1(11/3), which is about the general definition of finalization. 7.6.1(12/2) is specifically about assignment, the new paragraph fits naturally after it. Should we put the paragraph there instead? (Yes.)

(4) AI22-0002-1 eliminated the possibility of using an object to initialize a container aggregate. But the example at 4.3.5(61/5) uses such an object. This should be replaced by a parameterless function, right? (Yes.)

(5) The function in the example at 4.3.5(63/5) declares the Capacity parameter to be of subtype Integer. But a negative Capacity doesn’t make any sense; the subtype of the parameter should be Natural, right? (Yes.)

!recommendation

[Editor’s note: These fixes have been applied to Draft 2 of the Ada 202y RM, as they are simple and noticed during the creation of that draft. Editorials are generally applied to AIs that have not yet been approved by WG 9; but AIs that have been approved need a separate update.]

(1) Give the boilerplate in the plural form.

(2) Restore the missing sentence.

(3) Put the paragraph in the more natural place.

!wording

Replace 4.3.5(61/5) by:

function Empty_Map return Map_Type;

 

[Editor’s note: The paragraph numbers of this example and the following one have changed in the latest draft of the RM. We’ve used the paragraph numbers from the Ada 2022 RM here.]

Modify 4.3.5(63/5):

function Empty_Vector (Capacity : {Natural}[Integer] := 0)
   return Vector_Type;

Modify 4.5.2(9.8/6):

If the profile of an explicitly declared primitive equality operator of an untagged record type is type conformant with that of the corresponding predefined equality operator, the declaration shall occur before the type is frozen. In addition, no type shall have been derived from the untagged record type before the declaration of the primitive equality operator. If the untagged record type is declared immediately within the visible part of a package, and the overriding primitive equality operator is explicitly declared within the private part of the package, the operator shall be subtype conformant with the predefined or inherited operator that it overrides. In addition to the places where Legality Rules normally apply (see 12.3), {these rules}[this rule applies] also {apply }in the private part of an instance of a generic unit.

Add nothing after 7.6.1(11/3).

Add after 7.6.1(12/2):

When an assignment changes the value of at least one discriminant of a target object, every discriminant-dependent component of the previous value ceases to exist, and every discriminant-dependent component of the new value of the object is newly created.

AARM Ramification: Access to a component is erroneous after it ceases to exist. That means that any effect is allowed, which of course includes working as expected. Thus, this rule does not require an implementation to do anything.

If an assignment does not change the value of any discriminant, then any discriminant-dependent components continue to exist. If an implementation chooses to reallocate memory for such components upon assignment, it has to take care that no such reallocation occurs when no discriminants change. End AARM Ramification.

[Editor’s note: This text is unchanged from AI22-0062-1, just moved.]

Modify 10.2.1(18/6):

If a library unit is declared pure, then the implementation is permitted to omit a call on a library-level subprogram of the library unit if the results are not needed after the call. In addition, the implementation may omit a call on such a subprogram and simply reuse the results produced by an earlier call on the same subprogram, provided that:

{Redundant:[This permission applies even if the subprogram produces other side effects when called.]}

!discussion

(1) There are clearly three (related) rules, so the boilerplate should be plural. We also move the “also”; the boilerplate does appear in the RM both as “also applies” and “applies also”; the former seems more natural to the editor.

(2) It appears to be an oversight that the last, redundant, sentence was omitted. If it was important enough to state explicitly in Ada 95 (and Ada 2022), it probably still is. An alternative would be to make it a note or usage advice, but we opt for the least change and just replace it after the bullets.

(3) It’s possible that the paragraph reference was just botched in the original AI. Moving the paragraph also avoids renumbering 7.61(11.1-11.5).

(4) Obviously, the example needs to be consistent with the current rules.

(5) While this is only an example, it makes sense to show good practice in these examples. There is no meaning for a negative capacity (the Ada.Containers use Count_Type for capacity parameters; this type only has positive values). Since we have a handy subtype that excludes negative values, we should use it.

!example

None needed for presentation issues.

!corrigendum 4.3.5(61/5)

@drepl

@xcode{Empty_Map : @b{constant} Map_Type;}

@dby

@xcode{@b{function} Empty_Map @b{return} Map_Type;}

!corrigendum 4.3.5(63/5)

@drepl

@xcode{@b{function} Empty_Vector (Capacity : Integer := 0) @b{return} Vector_Type;}

@dby

@xcode{@b{function} Empty_Vector (Capacity : Natural := 0) @b{return} Vector_Type;}

!corrigendum 4.5.2(9.8/6)

@drepl

If the profile of an explicitly declared primitive equality operator of an untagged record type is type conformant with that of the corresponding predefined equality operator, the declaration shall occur before the type is frozen. In addition, no type shall have been derived from the untagged record type before the declaration of the primitive equality operator. If the untagged record type is declared immediately within the visible part of a package, and the overriding primitive equality operator is explicitly declared within the private part of the package, the operator shall be subtype conformant with the predefined or inherited operator that it overrides. In addition to the places where Legality Rules normally apply (see 12.3), this rule applies also in the private part of an instance of a generic unit.

@dby

If the profile of an explicitly declared primitive equality operator of an untagged record type is type conformant with that of the corresponding predefined equality operator, the declaration shall occur before the type is frozen. In addition, no type shall have been derived from the untagged record type before the declaration of the primitive equality operator. If the untagged record type is declared immediately within the visible part of a package, and the overriding primitive equality operator is explicitly declared within the private part of the package, the operator shall be subtype conformant with the predefined or inherited operator that it overrides. In addition to the places where Legality Rules normally apply (see 12.3), these rules also apply in the private part of an instance of a generic unit.

!corrigendum 7.6.1(12/2)

@dinsa

The target of an @fa{assignment_statement} is finalized before copying in the new value, as explained in 7.6.

@dinst

When an assignment changes the value of at least one discriminant of a target object, every discriminant-dependent component of the previous value ceases to exist, and every discriminant-dependent component of the new value of the object is newly created.

!corrigendum 10.2.1(18/6)

@drepl

If a library unit is declared pure, then the implementation is permitted to omit a call on a library-level subprogram of the library unit if the results are not needed after the call. In addition, the implementation may omit a call on such a subprogram and simply reuse the results produced by an earlier call on the same subprogram, provided that:

@xbullet{none of the parameters nor any object accessible via access values from the parameters have any part that is of a type whose full type is an immutably limited type; and}

@xbullet{the addresses and values of all by-reference actual parameters, the values of all by-copy-in actual parameters, and the values of all objects accessible via access values from the parameters, are the same as they were at the earlier call.}

@dby

If a library unit is declared pure, then the implementation is permitted to omit a call on a library-level subprogram of the library unit if the results are not needed after the call. In addition, the implementation may omit a call on such a subprogram and simply reuse the results produced by an earlier call on the same subprogram, provided that:

@xbullet{none of the parameters nor any object accessible via access values from the parameters have any part that is of a type whose full type is an immutably limited type; and}

@xbullet{the addresses and values of all by-reference actual parameters, the values of all by-copy-in actual parameters, and the values of all objects accessible via access values from the parameters, are the same as they were at the earlier call.}

This permission applies even if the subprogram produces other side

effects when called.

!ACATS test

No ACATS tests should be needed for presentation changes.

!appendix