AI22-0035-2

!standard A.4.2(25)                                    22-04-25  AI22-0035-2/01

!class binding interpretation 22-01-26

!status work item 22-01-26

!status received 22-01-26

!priority Low

!difficulty Easy

!qualifier Omission

!subject Add "not null" to type Character_Mapping_Function

!summary

As a binding interpretation, add "not null" to the declaration of the access-to-subprogram type Character_Mapping_Function in the Ada.Strings hierarchy.

!issue

Only in fine print does it say that passing in a null Character_Mapping_Function will result in a Constraint_Error (specifically, in A.4.3(109)). We could add "not null" to the parameter profiles where Character_Mapping_Function is used and is required to be nonnull, which would

be clearer. But in fact, every use of Character_Mapping_Function requires it to be non-null, so simpler seems to be to declare the type as not null access.  Should we do this? (Yes.)

!recommendation

(See Summary.)

!wording

In A.4.2(25), modify:

   type Character_Mapping_Function is{ not null}
     access function (From : in Character) return Character;

 

!discussion

Adding "not null" directly to the type definition is the simpler fix, as every language-defined use of Character_Mapping_Function requires the value to be nonnull.  However, if the type is used elsewhere in a program, the programmer will have to use a different type if they want to allow a null value.  This might justify making this an amendment, or adding a subtype that allows null explicitly, such as:

   type {Optional_}Character_Mapping_Function is
         access function (From : in Character) return Character;

{ subtype Character_Mapping_Function is not null
           Optional_Character_Mapping_Function;}

!ACATS test

No additional ACATS tests should be necessary.

!appendix

From: Tucker Taft

Sent: Friday, June 18, 2021  9:06 AM

An issue came up with the fact that only in fine print does it say that

passing in a null Character_Mapping_Function will result in a

Constraint_Error (e.g. A.4.3(109)).  It would seem appropriate to add a

"not null" to the parameter profiles where Character_Mapping_Function is

used and is required to be nonnull.  Changing the type itself to be null

excluding would be incompatible, but adding "not null" to the various

parameters would communicate the information as part of the subprogram

contract.

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