DocAda(tm) is a productivity tool of KSCE

Prev | Up | Next | Back | Forward
About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News

4.7 Qualified Expressions

A qualified_expression is used to state explicitly the type, and to verify the subtype, of an operand that is either an expression or an aggregate.

Syntax

   
       qualified_expression ::=
          subtype_mark'(expression) | subtype_mark'aggregate

Name Resolution Rules

The operand (the expression or aggregate) shall resolve to be of the type determined by the subtype_mark, or a universal type that covers it.

Dynamic Semantics

The evaluation of a qualified_expression evaluates the operand (and if of a universal type, converts it to the type determined by the subtype_mark) and checks that its value belongs to the subtype denoted by the subtype_mark. The exception Constraint_Error is raised if this check fails.

Examples

Examples of disambiguating expressions using qualification:

   
       type Mask is (Fix, Dec, Exp, Signif);
       type Code is (Fix, Cla, Dec, Tnz, Sub);

       Print (Mask'(Dec));  --  Dec is of type Mask
       Print (Code'(Dec));  --  Dec is of type Code

       for J in Code'(Fix) .. Code'(Dec) loop ... -- qualification needed for either Fix or Dec
       for J in Code range Fix .. Dec loop ...    -- qualification unnecessary
       for J in Code'(Fix) .. Dec loop ...        -- qualification unnecessary for Dec

       Dozen'(1 | 3 | 5 | 7 => 2, others => 0) -- see 4.6

About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News
Prev | Up | Next | Back | Forward


Copyright © 1994-1997 by Kempe Software Capital Enterprises. All Rights Reserved. For comments on this DocAda(tm) hypertext document, please write to KSCE, at docada@ksce.com