Version 1.1 of ai12s/ai12-0053-1.txt

Unformatted version of ai12s/ai12-0053-1.txt version 1.1
Other versions for file ai12s/ai12-0053-1.txt

!standard 3.2.4(31/3)          12-12-08 AI12-0053-1/01
!standard 4.6(57/3)
!class binding interpretation
!priority High
!difficulty Medium
!qualifier Error
!subject Predicate failure raises Constraint_Error
Predicate failure raises Constraint_Error, not Assertion_Error.
Should predicates raise Constraint_Error on failure? (Yes.)
See !summary.
31/3 ... {Constraint_Error}[Assertions.Assertion_Error] is raised if any of
these checks fail.
57/3 If an Accessibility_Check fails, Program_Error is raised. If a predicate check fails, {Constraint_Error}[Assertions.Assertion_Error] is raised. Any other check associated with a conversion raises Constraint_Error if it fails.
Predicates need to be interchangeable with constraints, so one can switch back and forth between them. Therefore, predicates need to raise Constraint_Error on failure. Having them raise Assertion_Error was a mistake.
As an example, see AI12-0037-1. The Ada.Locales package was originally designed to have these types:
type Language_Code is array (1 .. 3) of Character range 'a' .. 'z'; type Country_Code is array (1 .. 2) of Character range 'A' .. 'Z';
However, it was discovered that these types are not convertible to/from String, which makes it rather inconvenient to do text IO. Therefore, AI12-0037-1 changed the types to use predicates:
type Language_Code is new String(1 .. 3) with Dynamic_Predicate => (for all E of Language_Code => (E in 'a' .. 'z')); type Country_Code is new String(1 .. 2) with Dynamic_Predicate => (for all E of Country_Code => (E in 'A' .. 'Z'));
In order to preserve compatibility, it is important that this kind of change be possible without changing the exception that is raised on failure.

This AI was created out of discussion on AI12-0037-1 during ARG meeting
#48 in Boston.


Questions? Ask the ACAA Technical Agent