home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 3 / CDASC03.ISO / sorties / 118 / lrm_04 < prev    next >
Text File  |  1993-04-01  |  91KB  |  1,765 lines

  1.  
  2.  
  3. The Ada Joint Program Office does not guarantee the accuracy of this
  4. file, as compared with the contents of ANSI/MIL-STD-1815A-1983,
  5. the Reference Manual for the Ada Programming Language.  If errors or
  6. discrepancies are found in this machine-readable version, please 
  7. forward comments via the Defense Data Network (DDN) to:
  8.  
  9.                      ACTION@AJPO.SEI.CMU.EDU
  10.  
  11. or via conventional mail to
  12.  
  13.                   Ada Information Clearinghouse
  14.                    3D139 (1211 S. Fern, C-107)
  15.                          The Pentagon
  16.                    Washington, D.C.  20301-3081
  17.  
  18. -----------------------------------------------------------------------
  19.  
  20. Copyright 1980, 1982, 1983 owned by the United States Government as
  21. represented by the Under Secretary of Defense, Research and
  22. Engineering.  All rights reserved.  Provided that notice of copyright
  23. is included on the first page, this document may be copied in its
  24. entirety without alteration or as altered by (1) adding text that is
  25. clearly marked as an insertion; (2) shading or highlighting existing
  26. text; (3) deleting examples.  Permission to publish other excerpts
  27. should be obtained from the Ada Joint Program Office, OUSDRE (R&AT),
  28. The Pentagon, Washington, DC 20301-2081, U.S.A.
  29.  
  30.  
  31.  
  32.                          4. Names and Expressions   
  33.  
  34. The rules applicable to the different forms of name and expression, and  to
  35. their evaluation, are given in this chapter.   
  36.  
  37. 4.1  Names  
  38.  
  39. Names   can  denote  declared  entities,  whether  declared  explicitly  or
  40. implicitly (see 3.1).  Names can also denote objects designated  by  access
  41. values;   subcomponents  and slices of objects and values;  single entries,
  42. entry families, and entries in families of  entries.   Finally,  names  can
  43. denote attributes of any of the foregoing. 
  44.  
  45.     name ::= simple_name
  46.        | character_literal  | operator_symbol
  47.        | indexed_component  | slice
  48.        | selected_component | attribute 
  49.  
  50.     simple_name ::= identifier 
  51.  
  52.     prefix ::= name | function_call 
  53.  
  54. A  simple  name  for an entity is either the identifier associated with the
  55. entity by its declaration, or another identifier associated with the entity
  56. by a renaming declaration. 
  57.  
  58. Certain forms  of  name  (indexed  and  selected  components,  slices,  and
  59. attributes)  include a prefix that is either a name or a function call.  If
  60. the type of a prefix is an access type, then the prefix must not be a  name
  61. that denotes a formal parameter of mode out or a subcomponent thereof. 
  62.  
  63. If  the  prefix  of  a  name  is  a  function call, then the name denotes a
  64. component, a slice, an attribute, an entry, or an entry family,  either  of
  65. the  result  of the function call, or (if the result is an access value) of
  66. the object designated by the result. 
  67.  
  68. A prefix is said to be appropriate for a type in either  of  the  following
  69. cases: 
  70.  
  71.   -  The type of the prefix is the type considered. 
  72.  
  73.   -  The type of the prefix is an access type whose designated type is  the
  74.      type considered.    
  75.  
  76. The  evaluation  of a name determines the entity denoted by the name.  This
  77. evaluation has no other effect  for  a  name  that  is  a  simple  name,  a
  78. character literal, or an operator symbol. 
  79.  
  80. The  evaluation  of a name that has a prefix includes the evaluation of the
  81. prefix, that is, of the corresponding name or function call.  If  the  type
  82. of  the prefix is an access type, the evaluation of the prefix includes the
  83. determination of the object designated by the corresponding  access  value;
  84. the  exception  CONSTRAINT_ERROR  is raised if the value of the prefix is a
  85. null access value, except in the case of the  prefix  of  a  representation
  86. attribute (see 13.7.2).                                              
  87.  
  88. Examples of simple names: 
  89.  
  90.     PI      --  the simple name of a number               (see 3.2.2)
  91.     LIMIT   --  the simple name of a constant             (see 3.2.1)
  92.     COUNT   --  the simple name of a scalar variable      (see 3.2.1)
  93.     BOARD   --  the simple name of an array variable      (see 3.6.1)
  94.     MATRIX  --  the simple name of a type                 (see 3.6)
  95.     RANDOM  --  the simple name of a function             (see 6.1)
  96.     ERROR   --  the simple name of an exception           (see 11.1) 
  97.  
  98. References:   access type 3.8, access value 3.8, attribute 4.1.4, belong to
  99. a  type  3.3,  character  literal  2.5,  component  3.3,   constraint_error
  100. exception 11.1, declaration 3.1, designate 3.8, designated type 3.8, entity
  101. 3.1,  entry  9.5,  entry  family 9.5, evaluation 4.5, formal parameter 6.1,
  102. function call 6.4, identifier 2.3, indexed component 4.1.1, mode 6.1,  null
  103. access  value 3.8, object 3.2.1, operator symbol 6.1, raising of exceptions   
  104. 11, renaming declarations  8.5,  selected  component  4.1.3,  slice  4.1.2,
  105. subcomponent 3.3, type 3.3    
  106.  
  107. 4.1.1  Indexed Components  
  108.  
  109. An  indexed component denotes either a component of an array or an entry in
  110. a family of entries. 
  111.  
  112.     indexed_component ::= prefix(expression {, expression}) 
  113.  
  114. In the case of a component of an array, the prefix must be appropriate  for
  115. an array type.  The expressions specify the index values for the component;
  116. there  must  be  one  such  expression for each index position of the array
  117. type.  In the case of an entry in a family of entries, the prefix must be a
  118. name that denotes an  entry family of a task  object,  and  the  expression
  119. (there  must  be  exactly one) specifies the index value for the individual
  120. entry. 
  121.  
  122. Each expression must be of the type of the corresponding  index.   For  the
  123. evaluation  of  an  indexed  component,  the prefix and the expressions are
  124. evaluated in some order that is not defined by the language.  The exception
  125. CONSTRAINT_ERROR is raised if an index value does not belong to  the  range
  126. of the corresponding index of the prefixing array or entry family. 
  127.  
  128. Examples of indexed components: 
  129.  
  130.  MY_SCHEDULE(SAT)     --  a component of a one-dimensional array  (see 3.6.1)
  131.  PAGE(10)             --  a component of a one-dimensional array  (see 3.6)
  132.  BOARD(M, J + 1)      --  a component of a two-dimensional array  (see 3.6.1)
  133.  PAGE(10)(20)         --  a component of a component              (see 3.6)
  134.  REQUEST(MEDIUM)      --  an entry in a family of entries         (see 9.5)
  135.  NEXT_FRAME(L)(M, N)  --  a component of a function call          (see 6.1)
  136.  
  137. Notes on the examples:   
  138.  
  139. Distinct notations are used for components of multidimensional arrays (such
  140. as  BOARD) and arrays of arrays (such as PAGE).  The components of an array 
  141. of arrays are arrays and  can  therefore  be  indexed.   Thus  PAGE(10)(20)
  142. denotes  the 20th component of PAGE(10).  In the last example NEXT_FRAME(L)
  143. is  a  function  call  returning  an  access  value  which   designates   a
  144. two-dimensional array. 
  145.  
  146. References:   appropriate  for  a  type 4.1, array type 3.6, component 3.3,
  147. component of an array 3.6, constraint_error exception 11.1, dimension  3.6,
  148. entry  9.5, entry family 9.5, evaluation 4.5, expression 4.4, function call
  149. 6.4, in some order 1.6,  index  3.6,  name  4.1,  prefix  4.1,  raising  of
  150. exceptions 11, returned value 5.8 6.5, task object 9.2                                             
  151.  
  152. 4.1.2  Slices  
  153.  
  154. A slice denotes a one-dimensional array formed by a sequence of consecutive
  155. components  of  a  one-dimensional  array.   A  slice  of  a  variable is a
  156. variable;  a slice of a constant is a constant;  a slice of a  value  is  a
  157. value. 
  158.  
  159.     slice ::= prefix(discrete_range) 
  160.  
  161. The prefix of a slice must be appropriate for a one-dimensional array type.
  162. The  type  of the slice is the base type of this array type.  The bounds of
  163. the discrete range define those of the slice and must be of the type of the
  164. index;  the slice is a null slice denoting a null  array  if  the  discrete
  165. range is a null range. 
  166.  
  167. For  the  evaluation of a name that is a slice, the prefix and the discrete
  168. range are evaluated in some order that is not defined by the language.  The
  169. exception CONSTRAINT_ERROR is raised by the evaluation of  a  slice,  other
  170. than  a  null  slice,  if  any of the bounds of the discrete range does not
  171. belong to the index range of the prefixing array.  (The bounds  of  a  null
  172. slice need not belong to the subtype of the index.) 
  173.  
  174. Examples of slices: 
  175.  
  176.   STARS(1 .. 15)        --  a slice of 15 characters       (see 3.6.3)
  177.   PAGE(10 .. 10 + SIZE) --  a slice of 1 + SIZE components (see 3.6 and 3.2.1)
  178.   PAGE(L)(A .. B)       --  a slice of the array PAGE(L)   (see 3.6)
  179.   STARS(1 .. 0)         --  a null slice                   (see 3.6.3)
  180.   MY_SCHEDULE(WEEKDAY)  --  bounds given by subtype        (see 3.6 and 3.5.1)
  181.   STARS(5 .. 15)(K)     --  same as STARS(K)               (see 3.6.3)
  182.                         --  provided that K is in 5 .. 15
  183.  
  184. Notes: 
  185.  
  186. For  a  one-dimensional  array  A,  the  name  A(N  .. N) is a slice of one
  187. component;  its type is the base type of A.  On the other hand, A(N)  is  a
  188. component of the array A and has the corresponding component type. 
  189.  
  190. References:   appropriate  for a type 4.1, array 3.6, array type 3.6, array
  191. value 3.8, base type 3.3, belong to a subtype  3.3,  bound  of  a  discrete
  192. range  3.6.1, component 3.3, component type 3.3, constant 3.2.1, constraint
  193. 3.3, constraint_error exception 11.1, dimension 3.6,  discrete  range  3.6,
  194. evaluation  4.5,  index  3.6,  index range 3.6, name 4.1, null array 3.6.1,
  195. null range 3.5, prefix 4.1, raising of exceptions 11,  type  3.3,  variable
  196. 3.2.1   
  197.  
  198. 4.1.3  Selected Components  
  199.  
  200. Selected  components  are  used to denote record components, entries, entry
  201. families, and objects designated by access values; they are  also  used  as
  202. expanded names as described below.  
  203.  
  204.     selected_component ::= prefix.selector 
  205.  
  206.     selector ::= simple_name
  207.        | character_literal | operator_symbol | all                                                     
  208.  
  209. The  following  four  forms  of  selected  components  are used to denote a
  210. discriminant, a record component, an entry, or an object designated  by  an
  211. access value: 
  212.  
  213. (a)  A discriminant: 
  214.  
  215.      The  selector  must  be  a  simple  name denoting a discriminant of an
  216.      object or value.  The prefix must be appropriate for the type of  this
  217.      object or value. 
  218.  
  219. (b)  A component of a record: 
  220.  
  221.      The  selector  must  be a simple name denoting a component of a record
  222.      object or value.  The prefix must be appropriate for the type of  this
  223.      object or value. 
  224.  
  225.      For  a  component of a variant, a check is made that the values of the
  226.      discriminants are such  that  the  record  has  this  component.   The
  227.      exception CONSTRAINT_ERROR is raised if this check fails. 
  228.  
  229. (c)  A single entry or an entry family of a task: 
  230.  
  231.      The selector must be a simple name denoting a single entry or an entry
  232.      family of a task.  The prefix must be appropriate for the type of this
  233.      task. 
  234.  
  235. (d)  An object designated by an access value: 
  236.  
  237.      The  selector  must be the reserved word all.  The value of the prefix
  238.      must belong to an access type. 
  239.  
  240. A selected component of one  of  the  remaining  two  forms  is  called  an
  241. expanded  name.   In each case the selector must be either a simple name, a
  242. character literal, or an operator symbol.  A function call is  not  allowed
  243. as the prefix of an expanded name.  An expanded name can denote: 
  244.  
  245. (e)  An entity declared in the visible part of a package: 
  246.  
  247.      The  prefix  must denote the package.  The selector must be the simple
  248.      name, character literal, or operator symbol of the entity. 
  249.  
  250. (f)  An  entity  whose  declaration  occurs  immediately  within  a   named
  251.      construct: 
  252.  
  253.      The  prefix  must  denote a construct that is either a program unit, a
  254.      block statement, a loop statement, or an  accept  statement.   In  the  
  255.      case of an accept statement, the prefix must be either the simple name
  256.      of  the  entry or entry family, or an expanded name ending with such a
  257.      simple name (that is, no index is allowed).  The selector must be  the
  258.      simple  name, character literal, or operator symbol of an entity whose
  259.      declaration occurs immediately within the construct. 
  260.  
  261.      This form of expanded name is only allowed within the construct itself
  262.      (including the body and any subunits, in the case of a program  unit).
  263.      A  name  declared  by  a  renaming  declaration  is not allowed as the  
  264.      prefix.  If the prefix is the name of a subprogram or accept statement
  265.      and if there is more than one visible enclosing subprogram  or  accept
  266.      statement  of this name, the expanded name is ambiguous, independently
  267.      of the selector. 
  268.  
  269. If, according to the visibility rules,  there  is  at  least  one  possible
  270. interpretation  of  the  prefix  of  a selected component as the name of an
  271. enclosing subprogram or accept statement,  then  the  only  interpretations
  272. considered  are those of rule (f), as expanded names (no interpretations of
  273. the prefix as a function call are then considered).                                               
  274.  
  275. The evaluation of  a  name  that  is  a  selected  component  includes  the
  276. evaluation of the prefix. 
  277.  
  278. Examples of selected components: 
  279.  
  280.   TOMORROW.MONTH     --  a record component                    (see 3.7)
  281.   NEXT_CAR.OWNER     --  a record component                    (see 3.8.1)
  282.   NEXT_CAR.OWNER.AGE --  a record component                    (see 3.8.1)
  283.   WRITER.UNIT        --  a record component (a discriminant)   (see 3.7.3)
  284.   MIN_CELL(H).VALUE  --  a record component of the result  (see 6.1 and 3.8.1)
  285.                      --  of the function call MIN_CELL(H)
  286.   CONTROL.SEIZE      --  an entry of the task CONTROL      (see 9.1 and 9.2)
  287.   POOL(K).WRITE      --  an entry of the task POOL(K)      (see 9.1 and 9.2)
  288.  
  289.   NEXT_CAR.all       --  the object designated by
  290.                      --  the access variable NEXT_CAR       (see 3.8.1)
  291.  
  292. Examples of expanded names: 
  293.  
  294.   TABLE_MANAGER.INSERT --  a procedure of the visible part of a package
  295.                            (see 7.5)
  296.   KEY_MANAGER."<"      --  an operator of the visible part of a package
  297.                            (see 7.4.2)
  298.   DOT_PRODUCT.SUM      --  a variable declared in a procedure body (see 6.5)
  299.   BUFFER.POOL          --  a variable declared in a task unit (see 9.12)
  300.   BUFFER.READ          --  an entry of a task unit (see 9.12)
  301.   SWAP.TEMP            --  a variable declared in a block statement (see 5.6)
  302.   STANDARD.BOOLEAN     --  the name of a predefined type (see 8.6 and C)
  303.  
  304. Note:
  305.  
  306. For  a record with components that are other records, the above rules imply
  307. that the simple name must be  given  at  each  level  for  the  name  of  a
  308. subcomponent.   For  example, the name NEXT_CAR.OWNER.BIRTH.MONTH cannot be
  309. shortened (NEXT_CAR.OWNER.MONTH is not allowed). 
  310.  
  311. References:  accept statement 9.5,  access  type  3.8,  access  value  3.8,
  312. appropriate  for  a  type  4.1, block statement 5.6, body of a program unit
  313. 3.9, character literal 2.5, component of  a  record  3.7,  constraint_error
  314. exception  11.1,  declaration  3.1, designate 3.8, discriminant 3.3, entity
  315. 3.1, entry 9.5, entry family  9.5,  function  call  6.4,  index  3.6,  loop
  316. statement  5.5,  object  3.2.1, occur immediately within 8.1, operator 4.5,
  317. operator symbol 6.1, overloading 8.3, package 7, predefined type C,  prefix
  318. 4.1,  procedure  body 6.3, program unit 6, raising of exceptions 11, record
  319. 3.7, record component 3.7, renaming declaration  8.5,  reserved  word  2.9,
  320. simple  name 4.1, subprogram 6, subunit 10.2, task 9, task object 9.2, task
  321. unit 9, variable 3.7.3, variant 3.7.3, visibility 8.3, visible part 3.7.3   
  322.  
  323. 4.1.4  Attributes  
  324.  
  325. An attribute denotes a basic operation of an entity given by a prefix.   
  326.  
  327.     attribute ::= prefix'attribute_designator 
  328.  
  329.     attribute_designator ::= simple_name [(universal_static_expression)] 
  330.  
  331. The applicable attribute designators depend on the  prefix.   An  attribute
  332. can  be  a  basic  operation delivering a value;  alternatively it can be a
  333. function, a type, or a range.  The meaning of the prefix  of  an  attribute
  334. must   be  determinable  independently  of  the  attribute  designator  and
  335. independently of the fact that it is the prefix of an attribute.                                                
  336.  
  337. The attributes defined by the language  are  summarized  in  Annex  A.   In
  338. addition,  an implementation may provide implementation-defined attributes;
  339. their description must be given in Appendix F.  The attribute designator of
  340. any implementation-defined attribute must not be the same as  that  of  any
  341. language-defined attribute. 
  342.  
  343. The evaluation of a name that is an attribute consists of the evaluation of
  344. the prefix. 
  345.  
  346. Notes: 
  347.  
  348. The attribute designators DIGITS, DELTA, and RANGE have the same identifier
  349. as  a  reserved word.  However, no confusion is possible since an attribute  
  350. designator is always  preceded  by  an  apostrophe.   The  only  predefined
  351. attribute  designators  that  have  a  universal  expression  are those for
  352. certain operations of array types (see 3.6.2). 
  353.  
  354. Examples of attributes: 
  355.  
  356.   COLOR'FIRST        -- minimum value of the enumeration type COLOR
  357.                         (see 3.3.1 and 3.5)
  358.   RAINBOW'BASE'FIRST -- same as COLOR'FIRST (see 3.3.2 and 3.3.3)
  359.   REAL'DIGITS        -- precision of the type REAL (see 3.5.7 and 3.5.8)
  360.   BOARD'LAST(2)      -- upper bound of the second dimension of BOARD
  361.                         (see 3.6.1 and 3.6.2)
  362.   BOARD'RANGE(1)     -- index range of the first dimension of BOARD
  363.                         (see 3.6.1 and 3.6.2)
  364.   POOL(K)'TERMINATED -- TRUE if task POOL(K) is terminated (see 9.2 and 9.9)
  365.   DATE'SIZE          -- number of bits for records of type DATE
  366.                         (see 3.7   and 13.7.2)
  367.   MESSAGE'ADDRESS    -- address of the record variable MESSAGE
  368.                         (see 3.7.2 and 13.7.2)
  369.  
  370. References:  appropriate for a type 4.1, basic  operation  3.3.3,  declared
  371. entity  3.1,  name  4.1,  prefix  4.1,  reserved word 2.9, simple name 4.1,
  372. static expression 4.9, type 3.3, universal expression 4.1O   
  373.  
  374. 4.2  Literals  
  375.  
  376. A literal is either a numeric literal, an enumeration literal, the  literal
  377. null,  or  a  string  literal.   The  evaluation  of  a  literal yields the
  378. corresponding value. 
  379.  
  380. Numeric literals are  the  literals  of  the  types  universal_integer  and
  381. universal_real.   Enumeration literals include character literals and yield
  382. values of the corresponding enumeration types.  The literal null  yields  a
  383. null access value which designates no objects at all. 
  384.  
  385. A  string  literal  is  a  basic  operation  that  combines  a  sequence of
  386. characters into a value of a one-dimensional array  of  a  character  type;
  387. the  bounds  of  this  array  are  determined  according  to  the rules for 
  388. positional array aggregates (see 4.3.2).  For a null  string  literal,  the
  389. upper  bound  is  the  predecessor,  as given by the PRED attribute, of the
  390. lower bound.  The evaluation of a null string literal raises the  exception
  391. CONSTRAINT_ERROR  if  the  lower  bound  does  not  have a predecessor (see
  392. 3.5.5).   
  393.  
  394. The type of a string literal and likewise the type of the literal null must
  395. be determinable solely from the context  in  which  this  literal  appears,
  396. excluding the literal itself, but using the fact that the literal null is a
  397. value  of an access type, and similarly that a string literal is a value of
  398. a one-dimensional array type whose component type is a character type. 
  399.  
  400. The character literals corresponding to the  graphic  characters  contained
  401. within  a string literal must be visible at the place of the string literal
  402. (although these characters themselves are not used to determine the type of
  403. the string literal).                                               
  404.  
  405. Examples: 
  406.  
  407.     3.14159_26536  --  a real literal
  408.     1_345          --  an integer literal
  409.     CLUBS          --  an enumeration literal
  410.     'A'            --  a character literal
  411.     "SOME TEXT"    --  a string literal 
  412.  
  413. References:  access type 3.8, aggregate 4.3, array 3.6,  array  bound  3.6,
  414. array type 3.6, character literal 2.5, character type 3.5.2, component type
  415. 3.3,   constraint_error  exception  11.1,  designate  3.8,  dimension  3.6,
  416. enumeration literal 3.5.1, graphic character 2.1, integer literal 2.4, null
  417. access value 3.8, null literal 3.8, numeric literal 2.4, object 3.2.1, real  
  418. literal 2.4, string literal 2.6, type 3.3,  universal_integer  type  3.5.4,
  419. universal_real type 3.5.6, visibility 8.3   
  420.  
  421. 4.3  Aggregates  
  422.  
  423. An  aggregate  is  a  basic operation that combines component values into a
  424. composite value of a record or array type. 
  425.  
  426.     aggregate ::=
  427.        (component_association {, component_association}) 
  428.  
  429.     component_association ::=
  430.        [choice {| choice} => ] expression 
  431.  
  432. Each  component  association  associates  an  expression  with   components
  433. (possibly  none).   A  component  association  is  said  to be named if the
  434. components are specified explicitly by choices;  it is otherwise said to be
  435. positional.  For  a  positional  association,  the  (single)  component  is
  436. implicitly  specified  by  position,  in  the  order  of  the corresponding
  437. component declarations for record components,  in  index  order  for  array
  438. components. 
  439.  
  440. Named  associations  can  be  given  in  any  order  (except for the choice
  441. others), but if both positional and named associations are used in the same
  442. aggregate, then positional associations must occur first, at  their  normal
  443. position.   Hence  once  a  named  association  is  used,  the  rest of the
  444. aggregate must use only named associations.  Aggregates containing a single
  445. component association must always be given  in  named  notation.   Specific
  446. rules  concerning  component  associations  exist for record aggregates and
  447. array aggregates. 
  448.  
  449. Choices in component associations have the same syntax as in variant  parts
  450. (see 3.7.3).  A choice that is a component simple name is only allowed in a
  451. record  aggregate.   For a component association, a choice that is a simple
  452. expression or a discrete range is only allowed in an  array  aggregate;   a
  453. choice  that  is  a  simple  expression  specifies  the  component  at  the
  454. corresponding index  value;   similarly  a  discrete  range  specifies  the
  455. components  at  the  index  values in the range.  The choice others is only
  456. allowed in a component association if the association appears last and  has  
  457. this single choice;  it specifies all remaining components, if any. 
  458.  
  459. Each  component  of  the  value defined by an aggregate must be represented
  460. once and only once in the aggregate.  Hence each aggregate must be complete
  461. and a given component is not allowed to  be  specified  by  more  than  one
  462. choice. 
  463.  
  464. The  type  of  an aggregate must be determinable solely from the context in
  465. which the aggregate appears, excluding the aggregate itself, but using  the
  466. fact  that  this  type  must  be composite and not limited.  The type of an
  467. aggregate in turn determines the required type for each of its  components.                                              
  468.  
  469. Notes: 
  470.  
  471. The  above  rule implies that the determination of the type of an aggregate
  472. cannot use any information from within the aggregate.  In particular,  this
  473. determination  cannot  use  the  type  of  the  expression  of  a component
  474. association, or the form or the type of a choice.  An aggregate can  always
  475. be  distinguished  from  an  expression enclosed by parentheses:  this is a
  476. consequence of the fact that named notation is required  for  an  aggregate
  477. with a single component. 
  478.  
  479. References:   array aggregate 4.3.2, array type 3.6, basic operation 3.3.3,
  480. choice 3.7.3, component 3.3,  composite  type  3.3,  composite  value  3.3,
  481. discrete  range 3.6, expression 4.4, index 3.6, limited type 7.4.4, primary
  482. 4.4, record aggregate 4.3.1, record type 3.7, simple expression 4.4, simple
  483. name 4.1, type 3.3, variant part 3.7.3    
  484.  
  485. 4.3.1  Record Aggregates  
  486.  
  487. If the type of an aggregate is a record type, the component names given  as
  488. choices  must  denote  components  (including  discriminants) of the record
  489. type.  If the choice others is given as a choice of a record aggregate,  it
  490. must  represent  at  least one component.  A component association with the
  491. choice others or  with  more  than  one  choice  is  only  allowed  if  the
  492. represented  components  are  all  of  the  same type.  The expression of a
  493. component  association  must  have  the  type  of  the  associated   record
  494. components. 
  495.  
  496. The  value specified for a discriminant that governs a variant part must be
  497. given by a  static  expression  (note  that  this  value  determines  which
  498. dependent components must appear in the record value). 
  499.  
  500. For  the  evaluation  of  a  record aggregate, the expressions given in the
  501. component associations are evaluated in some order that is not  defined  by
  502. the  language.  The expression of a named association is evaluated once for
  503. each associated component.   A  check  is  made  that  the  value  of  each
  504. subcomponent  of the aggregate belongs to the subtype of this subcomponent.
  505.  
  506. The exception CONSTRAINT_ERROR is raised if this check fails. 
  507.  
  508. Example of a record aggregate with positional associations: 
  509.  
  510.     (4, JULY, 1776)                      --  see 3.7 
  511.  
  512. Examples of record aggregates with named associations: 
  513.  
  514.     (DAY => 4, MONTH => JULY, YEAR => 1776)
  515.     (MONTH => JULY, DAY => 4, YEAR => 1776) 
  516.  
  517.     (DISK, CLOSED, TRACK => 5, CYLINDER => 12)       --  see 3.7.3
  518.     (UNIT => DISK, STATUS => CLOSED, CYLINDER => 9, TRACK => 1) 
  519.  
  520. Example of component association with several choices:   
  521.  
  522.     (VALUE => 0, SUCC|PRED => new CELL'(0, null, null))   --  see 3.8.1
  523.  
  524.     --  The allocator is evaluated twice:  SUCC and PRED designate
  525.         different cells
  526.  
  527. Note:    
  528.  
  529. For an aggregate with positional associations, discriminant  values  appear
  530. first  since  the  discriminant  part  is  given  first  in the record type
  531. declaration;  they must be in the same order as in the  discriminant  part.                                                 
  532.  
  533. References:    aggregate   4.3,  allocator  4.8,  choice  3.7.3,  component
  534. association 4.3,  component  name  3.7,  constraint  3.3,  constraint_error
  535. exception   11.1,   depend  on  a  discriminant  3.7.1,  discriminant  3.3,
  536. discriminant part 3.7.1, evaluate 4.5, expression 4.4, in some  order  1.6,
  537. program  10,  raising  of  exceptions 11, record component 3.7, record type
  538. 3.7, satisfy 3.3, static expression 4.9, subcomponent 3.3,  subtype  3.3.2,
  539. type 3.3, variant part 3.7.3   
  540.  
  541. 4.3.2  Array Aggregates  
  542.  
  543. If  the  type  of  an  aggregate is a one-dimensional array type, then each
  544. choice must specify values of the index type, and the  expression  of  each
  545. component association must be of the component type. 
  546.  
  547. If  the  type  of  an  aggregate  is  a  multidimensional  array  type,  an
  548. n-dimensional aggregate is written as a one-dimensional aggregate, in which
  549. the expression specified for each component association is  itself  written
  550. as  an  (n-1)-dimensional  aggregate  which  is called a subaggregate;  the
  551. index subtype of the one-dimensional aggregate is given by the first  index
  552. position  of the array type.  The same rule is used to write a subaggregate
  553. if it is again  multidimensional,  using  successive  index  positions.   A
  554. string literal is allowed in a multidimensional aggregate at the place of a
  555. one-dimensional  array  of  a  character  type.  In what follows, the rules 
  556. concerning array aggregates are  formulated  in  terms  of  one-dimensional
  557. aggregates. 
  558.  
  559. Apart from a final component association with the single choice others, the
  560. rest  (if  any) of the component associations of an array aggregate must be
  561. either all positional or all  named.   A  named  association  of  an  array
  562. aggregate  is only allowed to have a choice that is not static, or likewise
  563. a choice that is a null range, if the aggregate includes a single component
  564. association and this component association has a single choice.  An  others
  565. choice is static if the applicable index constraint is static. 
  566.  
  567. The  bounds  of an array aggregate that has an others choice are determined
  568. by the applicable index constraint.  An others choice is  only  allowed  if
  569. the  aggregate  appears in one of the following contexts (which defines the
  570. applicable index constraint): 
  571.  
  572. (a)  The aggregate is an actual parameter, a generic actual parameter,  the
  573.      result  expression  of  a  function, or the expression that follows an
  574.      assignment  compound  delimiter.   Moreover,  the   subtype   of   the
  575.      corresponding  formal  parameter,  generic  formal parameter, function
  576.      result, or object is a constrained array subtype. 
  577.  
  578.      For an aggregate that appears  in  such  a  context  and  contains  an
  579.      association  with an others choice, named associations are allowed for
  580.      other associations only in the case of a (nongeneric) actual parameter
  581.      or function result.  If the aggregate  is  a  multidimensional  array,
  582.      this restriction also applies to each of its subaggregates.    
  583.  
  584. (b)  The aggregate is the operand of a qualified expression whose type mark
  585.      denotes a constrained array subtype. 
  586.  
  587. (c)  The aggregate is the expression of the  component  association  of  an   
  588.      enclosing  (array  or  record) aggregate.  Moreover, if this enclosing
  589.      aggregate is a multidimensional array aggregate then it is  itself  in
  590.      one of these three contexts. 
  591.  
  592. The  bounds  of  an array aggregate that does not have an others choice are
  593. determined as follows.  For an aggregate that has named  associations,  the
  594. bounds  are  determined  by  the smallest and largest choices given.  For a
  595. positional aggregate, the lower bound is determined by the applicable index
  596. constraint if the aggregate appears in one of the contexts (a) through (c);
  597. otherwise, the lower bound is  given  by  S'FIRST  where  S  is  the  index
  598. subtype;   in  either  case, the upper bound is determined by the number of
  599. components.                                                                       
  600.  
  601. The evaluation of an array aggregate that is not a subaggregate proceeds in
  602. two steps.  First, the choices of this aggregate and of its  subaggregates,
  603. if  any,  are  evaluated in some order that is not defined by the language.
  604. Second,  the  expressions  of  the  component  associations  of  the  array
  605. aggregate  are evaluated in some order that is not defined by the language;
  606. the expression of a named association is evaluated once for each associated
  607. component.  The evaluation of a subaggregate consists of this  second  step
  608. (the  first step is omitted since the choices have already been evaluated). 
  609.  
  610. For the evaluation of an aggregate that is not a null  array,  a  check  is
  611. made  that  the index values defined by choices belong to the corresponding
  612. index subtypes, and also  that  the  value  of  each  subcomponent  of  the
  613. aggregate   belongs   to   the   subtype  of  this  subcomponent.   For  an
  614. n-dimensional  multidimensional  aggregate,  a  check  is  made  that   all  
  615. (n-1)-dimensional  subaggregates  have  the  same  bounds.   The  exception
  616. CONSTRAINT_ERROR is raised if any of these checks fails.
  617.  
  618. Note: 
  619.  
  620. The allowed contexts for an array aggregate including an others choice  are
  621. such  that  the  bounds  of  such  an  aggregate  are always known from the
  622. context. 
  623.  
  624. Examples of array aggregates with positional associations: 
  625.  
  626.     (7, 9, 5, 1, 3, 2, 4, 8, 6, 0)
  627.     TABLE'(5, 8, 4, 1, others => 0)  --  see 3.6 
  628.  
  629. Examples of array aggregates with named associations: 
  630.  
  631.     (1 .. 5 => (1 .. 8 => 0.0))     --  two-dimensional
  632.     (1 .. N => new CELL)            --  N new cells, in particular for N =  0
  633.  
  634.     TABLE'(2 | 4 | 10 => 1, others => 0)
  635.     SCHEDULE'(MON .. FRI => TRUE,  others => FALSE)  --  see 3.6
  636.     SCHEDULE'(WED | SUN  => FALSE, others => TRUE)
  637.  
  638. Examples of two-dimensional array aggregates: 
  639.  
  640.     -- Three aggregates for the same value of type MATRIX (see 3.6):
  641.  
  642.     ((1.1, 1.2, 1.3), (2.1, 2.2, 2.3))
  643.     (1 => (1.1, 1.2, 1.3), 2 => (2.1, 2.2, 2.3))
  644.     (1 => (1 => 1.1, 2 => 1.2, 3 => 1.3), 2 => (1 => 2.1, 2 => 2.2, 3 => 2.3)) 
  645.  
  646. Examples of aggregates as initial values: 
  647.  
  648.   A : TABLE := (7, 9, 5, 1, 3, 2, 4, 8, 6, 0);        -- A(1)=7, A(10)= 8
  649.   B : TABLE := TABLE'(2 | 4 | 10 => 1, others => 0);  -- B(1)=0, B(10)=1
  650.   C : constant MATRIX := (1 .. 5 => (1 .. 8 => 0.0));
  651.                                                  -- C'FIRST(1)=1, C'LAST(2)=8
  652.  
  653.   D : BIT_VECTOR(M .. N) := (M .. N => TRUE);  -- see 3.6
  654.   E : BIT_VECTOR(M .. N) := (others => TRUE);
  655.   F : STRING(1 .. 1) := (1 => 'F');  -- a one component aggregate: same as "F"
  656.  
  657. References:   actual  parameter  6.4.1,  aggregate  4.3,  array  type  3.6,
  658. assignment  compound  delimiter 5.2, choice 3.7.3, component 3.3, component
  659. association  4.3,  component  type  3.3,  constrained  array  subtype  3.6,   
  660. constraint  3.3,  constraint_error  exception 11.1, dimension 3.6, evaluate
  661. 4.5, expression 4.4, formal parameter 6.1, function 6.5, in some order 1.6,
  662. index constraint 3.6.1, index range 3.6, index subtype 3.6, index type 3.6,
  663. named component association 4.3, null array 3.6.1, object  3.2,  positional
  664. component  association 4.3, qualified expression 4.7, raising of exceptions
  665. 11, static expression 4.9, subcomponent 3.3, type 3.3                                                
  666.  
  667. 4.4  Expressions  
  668.  
  669. An expression is a formula that defines the computation of a value. 
  670.  
  671.     expression ::=
  672.          relation {and relation} | relation {and then relation}
  673.        | relation {or relation}  | relation {or else relation}
  674.        | relation {xor relation} 
  675.  
  676.     relation ::=
  677.          simple_expression [relational_operator simple_expression]
  678.        | simple_expression [not] in range
  679.        | simple_expression [not] in type_mark 
  680.  
  681.     simple_expression ::= [unary_adding_operator]
  682.                           term {binary_adding_operator term}
  683.  
  684.     term ::= factor {multiplying_operator factor} 
  685.  
  686.     factor ::= primary [** primary] | abs primary | not primary 
  687.  
  688.     primary ::=
  689.        numeric_literal | null | aggregate | string_literal | name | allocator
  690.      | function_call | type_conversion | qualified_expression | (expression)
  691.  
  692. Each primary has a value and a type.  The only names allowed  as  primaries
  693. are  named  numbers;   attributes  that  yield  values;  and names denoting
  694. objects (the value of such a  primary  is  the  value  of  the  object)  or
  695. denoting  values.   Names that denote formal parameters of mode out are not
  696. allowed as primaries;  names of their subcomponents are only allowed in the
  697. case of discriminants.  
  698.  
  699. The type of an expression depends only on the type of its constituents  and
  700. on  the  operators applied;  for an overloaded constituent or operator, the
  701. determination of  the  constituent  type,  or  the  identification  of  the
  702. appropriate   operator,  depends  on  the  context.   For  each  predefined
  703. operator, the operand and result types are given in section 4.5. 
  704.  
  705. Examples of primaries: 
  706.  
  707.     4.0                --  real literal
  708.     PI                 --  named number
  709.     (1 .. 10 => 0)     --  array aggregate
  710.     SUM                --  variable
  711.     INTEGER'LAST       --  attribute
  712.     SINE(X)            --  function call
  713.     COLOR'(BLUE)       --  qualified expression
  714.     REAL(M*N)          --  conversion
  715.     (LINE_COUNT + 10)  --  parenthesized expression 
  716.  
  717. Examples of expressions: 
  718.  
  719.     VOLUME                  -- primary
  720.     not DESTROYED           -- factor
  721.     2*LINE_COUNT            -- term  
  722.     -4.0                      -- simple expression
  723.     -4.0 + A                  -- simple expression
  724.     B**2 - 4.0*A*C            -- simple expression
  725.     PASSWORD(1 .. 3) = "BWV"    -- relation
  726.     COUNT in SMALL_INT          -- relation
  727.     COUNT not in SMALL_INT      -- relation
  728.     INDEX = 0 or ITEM_HIT         -- expression
  729.     (COLD and SUNNY) or WARM      -- expression (parentheses are required)
  730.     A**(B**C)                     -- expression (parentheses are required)                                                
  731.  
  732. References:  aggregate 4.3, allocator 4.8, array aggregate 4.3.2, attribute
  733. 4.1.4, binary adding operator 4.5 4.5.3,  context  of  overload  resolution  
  734. 8.7,  exponentiating  operator  4.5  4.5.6,  function call 6.4, multiplying
  735. operator 4.5 4.5.5, name 4.1, named number 3.2, null literal  3.8,  numeric
  736. literal  2.4,  object  3.2,  operator  4.5, overloading 8.3, overloading an
  737. operator 6.7, qualified  expression  4.7,  range  3.5,  real  literal  2.4,
  738. relation  4.5.1,  relational  operator  4.5  4.5.2, result type 6.1, string
  739. literal 2.6, type 3.3, type conversion 4.6, type mark 3.3.2,  unary  adding
  740. operator 4.5 4.5.4, variable 3.2.1   
  741.  
  742. 4.5  Operators and Expression Evaluation  
  743.  
  744. The   language  defines  the  following  six  classes  of  operators.   The
  745. corresponding operator symbols (except /=), and only those, can be used  as
  746. designators  in declarations of functions for user-defined operators.  They
  747. are given in the order of increasing precedence. 
  748.  
  749.     logical_operator             ::=  and | or  | xor 
  750.     relational_operator          ::=  =   | /=  | <   | <= | > | >= 
  751.     binary_adding_operator       ::=  +   | -   | & 
  752.     unary_adding_operator        ::=  +   | - 
  753.     multiplying_operator         ::=  *   | /   | mod | rem 
  754.     highest_precedence_operator  ::=  **  | abs | not 
  755.  
  756. The short-circuit control  forms  and  then  and  or  else  have  the  same
  757. precedence  as  logical operators.  The membership tests in and not in have
  758. the same precedence as relational operators. 
  759.  
  760. For a term, simple expression, relation, or expression, operators of higher
  761. precedence are associated with their operands  before  operators  of  lower
  762. precedence.   In  this  case,  for  a  sequence  of  operators  of the same
  763. precedence level, the operators are associated in textual order  from  left
  764. to right;  parentheses can be used to impose specific associations. 
  765.  
  766. The  operands  of  a  factor,  of  a  term, of a simple expression, or of a
  767. relation, and the operands  of  an  expression  that  does  not  contain  a
  768. short-circuit control form, are evaluated in some order that is not defined
  769. by  the  language  (but  before application of the corresponding operator).
  770. The right operand of a short-circuit control form is evaluated if and  only
  771. if the left operand has a certain value (see 4.5.1). 
  772.  
  773. For  each  form  of  type  declaration,  certain of the above operators are
  774. predefined, that is, they are implicitly declared by the type  declaration.
  775. For  each  such  implicit operator declaration, the names of the parameters
  776. are LEFT and RIGHT for binary operators;  the single  parameter  is  called
  777. RIGHT  for  unary adding operators and for the unary operators abs and not.
  778. The effect of the predefined operators is explained  in  subsections  4.5.1  
  779. through 4.5.7. 
  780.  
  781. The  predefined operations on integer types either yield the mathematically
  782. correct  result  or  raise  the  exception  NUMERIC_ERROR.   A   predefined
  783. operation   that   delivers  a  result  of  an  integer  type  (other  than
  784. universal_integer) can  only  raise  the  exception  NUMERIC_ERROR  if  the
  785. mathematical  result is not a value of the type.  The predefined operations
  786. on real types yield results whose accuracy is defined in section 4.5.7.   A
  787. predefined  operation  that  delivers  a  result of a real type (other than
  788. universal_real) can only raise the exception NUMERIC_ERROR if the result is
  789. not within the range of the safe numbers  of  the  type,  as  explained  in
  790. section 4.5.7.                                                                      
  791.  
  792. Examples of precedence: 
  793.  
  794.     not SUNNY or WARM    --  same as (not SUNNY) or WARM
  795.     X > 4.0 and Y > 0.0  --  same as (X > 4.0) and (Y > 0.0)    
  796.  
  797.     -4.0*A**2            --  same as -(4.0 * (A**2))
  798.     abs(1 + A) + B       --  same as (abs (1 + A)) + B
  799.     Y**(-3)              --  parentheses are necessary
  800.     A / B * C            --  same as (A/B)*C
  801.     A + (B + C)          --  evaluate B + C before adding it to A 
  802.  
  803. References:    designator   6.1,   expression  4.4,  factor  4.4,  implicit
  804. declaration 3.1, in some order 1.6, integer  type  3.5.4,  membership  test
  805. 4.5.2, name 4.1, numeric_error exception 11.1, overloading 6.6 8.7, raising
  806. of  an  exception 11, range 3.5, real type 3.5.6, relation 4.4, safe number
  807. 3.5.6, short-circuit control form 4.5 4.5.1, simple  expression  4.4,  term
  808. 4.4,  type  3.3,  type  declaration  3.3.1,  universal_integer  type 3.5.4,
  809. universal_real type 3.5.6   
  810.  
  811. 4.5.1  Logical Operators and Short-circuit Control Forms  
  812.  
  813. The following logical operators are predefined for any boolean type and any
  814. one-dimensional array type whose components are  of  a  boolean  type;   in
  815. either case the two operands have the same type. 
  816.  
  817. Operator  Operation              Operand type                 Result type
  818.  
  819. and     conjunction            any boolean type             same boolean type
  820.                                array of boolean components  same array type
  821. or      inclusive disjunction  any boolean type             same boolean type
  822.                                array of boolean components  same array type
  823. xor     exclusive disjunction  any boolean type             same boolean type
  824.                                array of boolean components  same array type
  825.  
  826. The operations on arrays are performed on a component-by-component basis on
  827. matching  components,  if  any (as for equality, see 4.5.2).  The bounds of
  828. the resulting array are those of the left operand.  A check  is  made  that
  829. for each component of the left operand there is a matching component of the
  830. right operand, and vice versa.  The exception CONSTRAINT_ERROR is raised if
  831. this check fails. 
  832.  
  833. The  short-circuit  control  forms and then and or else are defined for two
  834. operands of a boolean type and deliver a result of the same type.  The left
  835. operand of a short-circuit control form is always evaluated first.  If  the
  836. left  operand  of an expression with the control form and then evaluates to
  837. FALSE, the right operand is not evaluated and the value of  the  expression
  838. is  FALSE.   If  the left operand of an expression with the control form or
  839. else evaluates to TRUE, the right operand is not evaluated and the value of
  840. the expression is TRUE.  If both operands are evaluated, and then  delivers
  841. the same result as and, and or else delivers the same result as or.  
  842.  
  843. Note:
  844.  
  845. The  conventional  meaning  of  the  logical operators is given by the fol-
  846. lowing truth table:
  847.  
  848.     A        B       (A and B)    (A or B)    (A xor B) 
  849.  
  850.     TRUE    TRUE     TRUE         TRUE        FALSE
  851.     TRUE    FALSE    FALSE        TRUE        TRUE
  852.     FALSE   TRUE     FALSE        TRUE        TRUE
  853.     FALSE   FALSE    FALSE        FALSE       FALSE                                                
  854.  
  855. Examples of logical operators: 
  856.  
  857.     SUNNY or WARM
  858.     FILTER(1 .. 10) and FILTER(15 .. 24)   --   see 3.6.1 
  859.  
  860. Examples of short-circuit control forms: 
  861.  
  862.     NEXT_CAR.OWNER /= null and then NEXT_CAR.OWNER.AGE > 25   --   see 3.8.1
  863.     N = 0 or else A(N) = HIT_VALUE 
  864.  
  865. References:  array type 3.6, boolean type 3.5.3, bound of  an  index  range
  866. 3.6.1,   component  of  an  array  3.6,  constraint_error  exception  11.1,   
  867. dimension 3.6, false boolean  value  3.5.3,  index  subtype  3.6,  matching
  868. components  of arrays 4.5.2, null array 3.6.1, operation 3.3, operator 4.5,
  869. predefined operator 4.5, raising  of  exceptions  11,  true  boolean  value
  870. 3.5.3, type 3.3   
  871.  
  872. 4.5.2  Relational Operators and Membership Tests  
  873.  
  874. The  equality  and inequality operators are predefined for any type that is
  875. not limited.  The other relational operators are the ordering  operators  <
  876. (less  than),  <=  (less  than or equal), > (greater than), and >= (greater
  877. than or equal).  The ordering operators   are  predefined  for  any  scalar
  878. type,  and  for  any  discrete array type, that is, a one-dimensional array
  879. type whose components are  of  a  discrete  type.   The  operands  of  each
  880. predefined  relational operator have the same type.  The result type is the
  881. predefined type BOOLEAN. 
  882.  
  883. The relational operators have their conventional meaning:   the  result  is
  884. equal  to  TRUE  if the corresponding relation is satisfied;  the result is
  885. FALSE otherwise.  The inequality operator gives the complementary result to
  886. the equality operator:  FALSE if equal, TRUE if not equal. 
  887.  
  888.     Operator    Operation                 Operand type          Result type 
  889.  
  890.     = /=        equality and inequality   any type              BOOLEAN 
  891.  
  892.     < <= > >=   test for ordering         any scalar type       BOOLEAN
  893.                                           discrete array type   BOOLEAN 
  894.  
  895. Equality for the discrete types  is  equality  of  the  values.   For  real
  896. operands  whose  values  are  nearly  equal,  the results of the predefined
  897. relational operators are given in section 4.5.7.   Two  access  values  are
  898. equal either if they designate the same object, or if both are equal to the
  899. null value of the access type. 
  900.  
  901. For  two  array  values  or  two  record  values of the same type, the left
  902. operand is equal to the right operand if and only if for each component  of
  903. the  left  operand  there  is a matching component of the right operand and
  904. vice versa;  and the values of matching components are equal, as  given  by
  905. the  predefined  equality  operator for the component type.  In particular,
  906. two null arrays of the same type are always equal;  two null records of the  
  907. same type are always equal. 
  908.  
  909. For comparing two records of the same type, matching components  are  those
  910. which have the same component identifier. 
  911.  
  912. For  comparing  two  one-dimensional  arrays  of  the  same  type, matching
  913. components are those (if any) whose index values  match  in  the  following
  914. sense:   the lower bounds of the index ranges are defined to match, and the
  915. successors of matching indices are defined to  match.   For  comparing  two
  916. multidimensional  arrays,  matching components are those whose index values
  917. match in successive index positions.                                              
  918.  
  919. If equality is explicitly defined for a limited type, it does not extend to
  920. composite  types  having  subcomponents  of  the  limited  type   (explicit
  921. definition of equality is allowed for such composite types). 
  922.  
  923. The ordering operators <, <=, >, and >= that are defined for discrete array
  924. types correspond to lexicographic order using the predefined order relation
  925. of  the  component  type.   A null array is lexicographically less than any
  926. array having at least one component.  In the case of  nonnull  arrays,  the
  927. left  operand is lexicographically less than the right operand if the first
  928. component of the left operand is less than that of  the  right;   otherwise
  929. the  left  operand is lexicographically less than the right operand only if   
  930. their first components are equal and  the  tail  of  the  left  operand  is
  931. lexicographically  less  than  that  of the right (the tail consists of the
  932. remaining components beyond the first and can be null). 
  933.  
  934. The membership tests in and not in  are  predefined  for  all  types.   The
  935. result  type  is the predefined type BOOLEAN.  For a membership test with a
  936. range, the simple expression and the bounds of the range  must  be  of  the
  937. same  scalar type;  for a membership test with a type mark, the type of the
  938. simple expression must be the base type of the type mark.   The  evaluation
  939. of the membership test in yields the result TRUE if the value of the simple
  940. expression  is  within  the  given  range,  or if this value belongs to the
  941. subtype denoted by the given type mark;  otherwise this  evaluation  yields
  942. the  result  FALSE (for a value of a real type, see 4.5.7).  The membership
  943. test not in gives the complementary result to the membership test in. 
  944.  
  945. Examples: 
  946.  
  947.     X /= Y
  948.  
  949.     "" < "A" and "A" < "AA"     --  TRUE
  950.     "AA" < "B" and "A" < "A  "  --  TRUE
  951.  
  952.     MY_CAR = null              -- true if MY_CAR has been set to null
  953.                                   (see 3.8.1)
  954.     MY_CAR = YOUR_CAR          -- true if we both share the same car
  955.     MY_CAR.all = YOUR_CAR.all  -- true if the two cars are identical
  956.  
  957.     N not in 1 .. 10     -- range membership test
  958.     TODAY in MON .. FRI  -- range membership test
  959.     TODAY in WEEKDAY     -- subtype membership test (see 3.5.1)
  960.     ARCHIVE in DISK_UNIT -- subtype membership test (see 3.7.3)
  961.  
  962. Notes:
  963.  
  964. No exception is ever raised by a predefined relational  operator  or  by  a
  965. membership  test,  but  an exception can be raised by the evaluation of the
  966. operands. 
  967.  
  968. If a record type has components that depend on discriminants, two values of
  969. this type have matching components if and only if their  discriminants  are
  970. equal.   Two  nonnull  arrays  have  matching components if and only if the 
  971. value of the attribute LENGTH(N) for each index position N is the same  for
  972. both.    
  973.  
  974. References:   access  value 3.8, array type 3.6, base type 3.3, belong to a
  975. subtype 3.3, boolean predefined type 3.5.3, bound of a range 3.5, component
  976. 3.3, component identifier 3.7, component  type  3.3,  composite  type  3.3,
  977. designate  3.8, dimension 3.6, discrete type 3.5, evaluation 4.5, exception
  978. 11, index 3.6, index range 3.6, limited type 7.4.4, null access value  3.8,
  979. null  array  3.6.1,  null record 3.7, object 3.2.1, operation 3.3, operator
  980. 4.5, predefined operator 4.5, raising of exceptions 11, range  3.5,  record
  981. type  3.7,  scalar  type  3.5,  simple  expression  4.4,  subcomponent 3.3,
  982. successor 3.5.5, type 3.3, type mark 3.3.2                                                
  983.  
  984. 4.5.3  Binary Adding Operators  
  985.  
  986. The binary adding operators + and -  are predefined for  any  numeric  type
  987. and  have  their  conventional  meaning.   The  catenation  operators & are
  988. predefined for any one-dimensional array type that is not limited. 
  989.  
  990. Operator  Operation Left operand type   Right operand type  Result type
  991.  
  992.  +    addition     any numeric type     same numeric type   same numeric type
  993.  
  994.  -    subtraction  any numeric type     same numeric type   same numeric type
  995.  
  996.  &    catenation   any array type       same array type      same array type
  997.                    any array type       the component type   same array type
  998.                    the component type   any array type       same array type
  999.                    the component type   the component type   any array type
  1000.  
  1001. For real types, the accuracy of the result is  determined  by  the  operand
  1002. type (see 4.5.7). 
  1003.  
  1004. If  both  operands are one-dimensional arrays, the result of the catenation
  1005. is a one-dimensional array whose length is the sum of the  lengths  of  its
  1006. operands,  and whose components comprise the components of the left operand
  1007. followed by the components of the right operand.  The lower bound  of  this
  1008. result is the lower bound of the left operand, unless the left operand is a
  1009. null  array,  in  which  case  the  result  of  the catenation is the right
  1010. operand.
  1011.  
  1012. If either operand is of the component type of an array type, the result  of
  1013. the  catenation is given by the above rules, using in place of this operand
  1014. an array having this operand as its only component  and  having  the  lower
  1015. bound of the index subtype of the array type as its lower bound. 
  1016.  
  1017. The  exception  CONSTRAINT_ERROR is raised by catenation if the upper bound
  1018. of the result exceeds the range of the index subtype, unless the result  is
  1019. a  null  array.   This  exception  is  also raised if any operand is of the
  1020. component type but has a value  that  does  not  belong  to  the  component
  1021. subtype. 
  1022.  
  1023. Examples: 
  1024.  
  1025.     Z + 0.1      --  Z must be of a real type 
  1026.  
  1027.     "A" & "BCD"  --  catenation of two string literals
  1028.     'A' & "BCD"  --  catenation of a character literal and a string literal
  1029.     'A' & 'A'    --  catenation of two character literals 
  1030.  
  1031. References:   array  type  3.6,  character literal 2.5, component type 3.3,
  1032. constraint_error exception 11.1, dimension 3.6, index subtype  3.6,  length
  1033. of  an array 3.6.2, limited type 7.4.4, null array 3.6.1, numeric type 3.5,
  1034. operation 3.3, operator 4.5, predefined operator 4.5, raising of exceptions
  1035. 11, range of an index subtype 3.6.1, real type 3.5.6, string  literal  2.6,
  1036. type 3.3   
  1037.  
  1038. 4.5.4  Unary Adding Operators   
  1039.  
  1040. The  unary adding operators + and - are predefined for any numeric type and
  1041. have their conventional meaning.  For each of these operators, the  operand
  1042. and the result have the same type.                                                   
  1043.  
  1044.     Operator   Operation   Operand type       Result type 
  1045.  
  1046.     +          identity    any numeric type   same numeric type 
  1047.  
  1048.     -          negation    any numeric type   same numeric type 
  1049.  
  1050. References:   numeric  type  3.5,  operation  3.3, operator 4.5, predefined
  1051. operator 4.5, type 3.3   
  1052.  
  1053. 4.5.5  Multiplying Operators  
  1054.  
  1055. The operators * and / are predefined for any integer and any floating point
  1056. type and have their conventional meaning;  the operators mod  and  rem  are
  1057. predefined for any integer type.  For each of these operators, the operands
  1058. and  the  result  have  the  same base type.  For floating point types, the
  1059. accuracy of the result is determined by the operand type (see 4.5.7). 
  1060.  
  1061.  Operator     Operation          Operand type           Result type
  1062.  
  1063.    *          multiplication     any integer type       same integer type
  1064.                                  any floating point     same floating point
  1065.                                  type                   type
  1066.    /          integer division   any integer type       same integer type
  1067.               floating division  any floating point     same floating point
  1068.                                  type                   type
  1069.   mod         modulus            any integer type       same integer type
  1070.   rem         remainder          any integer type       same integer type
  1071.  
  1072. Integer division and remainder are defined by the relation 
  1073.  
  1074.     A = (A/B)*B + (A rem B) 
  1075.  
  1076. where (A rem B) has the sign of A and  an  absolute  value  less  than  the 
  1077. absolute value of B.  Integer division satisfies the identity 
  1078.  
  1079.     (-A)/B = -(A/B) = A/(-B) 
  1080.  
  1081. The  result of the modulus operation is such that (A mod B) has the sign of
  1082. B and an absolute value less than the absolute value of  B;   in  addition,
  1083. for some integer value N, this result must satisfy the relation 
  1084.  
  1085.     A = B*N + (A mod B) 
  1086.  
  1087. For  each  fixed  point  type,  the  following  multiplication and division
  1088. operators, with an operand of the predefined type INTEGER, are  predefined. 
  1089.  
  1090.  Operator   Operation   Left operand      Right operand     Result type
  1091.                         type              type
  1092.  
  1093.    *        multiply    any fixed point   INTEGER           same as left
  1094.                         type
  1095.  
  1096.                         INTEGER           any fixed point   same as right
  1097.                                           type
  1098.  
  1099.    /        division    any fixed point   INTEGER           same as left                         
  1100.                         type
  1101.  
  1102. Integer  multiplication  of  fixed  point  values is equivalent to repeated
  1103. addition.  Division of a fixed point value by an integer does not involve a
  1104. change in type but is approximate (see 4.5.7). 
  1105.  
  1106. Finally, the following multiplication and division operators  are  declared
  1107. in  the  predefined package STANDARD.  These two special operators apply to
  1108. operands of all fixed point types (it is a consequence of other rules  that
  1109. they cannot be renamed or given as generic actual parameters). 
  1110.  
  1111. Operator  Operation  Left operand      Right operand      Result type
  1112.                      type              type
  1113.  
  1114.   *       multiply   any fixed point   any fixed point    universal_fixed
  1115.                      type              type
  1116.  
  1117.   /       divide     any fixed point   any fixed point    universal_fixed
  1118.                      type              type
  1119.  
  1120. Multiplication of operands of the same or of different fixed point types is
  1121. exact  and  delivers  a result of the anonymous predefined fixed point type
  1122. universal_fixed whose delta is arbitrarily small.  The result of  any  such
  1123. multiplication  must  always  be explicitly converted to some numeric type.
  1124. This ensures explicit control of the accuracy of the computation.  The same
  1125. considerations apply to division of a fixed point value  by  another  fixed
  1126. point  value.  No other operators are defined for the type universal_fixed. 
  1127.  
  1128. The exception NUMERIC_ERROR is raised by integer division, rem, and mod  if
  1129. the right operand is zero.  
  1130.  
  1131. Examples: 
  1132.  
  1133.     I : INTEGER := 1;
  1134.     J : INTEGER := 2;
  1135.     K : INTEGER := 3; 
  1136.  
  1137.     X : REAL digits 6 := 1.0;             --     see 3.5.7
  1138.     Y : REAL digits 6 := 2.0; 
  1139.  
  1140.     F : FRACTION delta 0.0001  := 0.1;        --     see 3.5.9
  1141.     G : FRACTION delta 0.0001  := 0.1;
  1142.  
  1143.     Expression        Value     Result Type 
  1144.  
  1145.     I*J               2         same as I and J, that is, INTEGER
  1146.     K/J               1         same as K and J, that is, INTEGER
  1147.     K mod J           1         same as K and J, that is, INTEGER 
  1148.  
  1149.     X/Y               0.5       same as X and Y, that is, REAL
  1150.     F/2               0.05      same as F, that is, FRACTION 
  1151.  
  1152.     3*F               0.3       same as F, that is, FRACTION
  1153.     F*G               0.01      universal_fixed, conversion needed
  1154.     FRACTION(F*G)     0.01      FRACTION, as stated by the conversion
  1155.     REAL(J)*Y         4.0       REAL, the type of both operands after
  1156.                                 conversion of J                                          
  1157.  
  1158. Notes: 
  1159.  
  1160. For positive A and B, A/B is the quotient and A rem B is the remainder when
  1161. A  is  divided  by  B.   The  following  relations are satisfied by the rem   
  1162. operator: 
  1163.  
  1164.     A    rem (-B) =   A rem B
  1165.     (-A) rem   B  = -(A rem B) 
  1166.  
  1167. For any integer K, the following identity holds: 
  1168.  
  1169.       A  mod   B  =  (A + K*B) mod B 
  1170.  
  1171. The  relations  between  integer  division,  remainder,  and  modulus   are
  1172. illustrated by the following table:  
  1173.  
  1174.    A      B   A/B   A rem B  A mod B     A     B    A/B   A rem B   A mod B
  1175.  
  1176.    10     5    2       0        0       -10    5    -2       0         0
  1177.    11     5    2       1        1       -11    5    -2      -1         4
  1178.    12     5    2       2        2       -12    5    -2      -2         3
  1179.    13     5    2       3        3       -13    5    -2      -3         2
  1180.    14     5    2       4        4       -14    5    -2      -4         1
  1181.  
  1182.    10    -5   -2       0        0       -10   -5     2       0         8
  1183.    11    -5   -2       1       -4       -11   -5     2      -1        -1
  1184.    12    -5   -2       2       -3       -12   -5     2      -2        -2
  1185.    13    -5   -2       3       -2       -13   -5     2      -3        -3
  1186.    14    -5   -2       4       -1       -14   -5     2      -4        -4
  1187.  
  1188. References:   actual parameter 6.4.1, base type 3.3, declaration 3.1, delta
  1189. of a fixed point type 3.5.9, fixed point type 3.5.9,  floating  point  type
  1190. 3.5.7,  generic  formal  subprogram  12.1, integer type 3.5.4, numeric type
  1191. 3.5, numeric_error exception 11.1,  predefined  operator  4.5,  raising  of
  1192. exceptions  11,  renaming declaration 8.5, standard predefined package 8.6,
  1193. type conversion 4.6   
  1194.  
  1195. 4.5.6  Highest Precedence Operators  
  1196.  
  1197. The highest precedence unary operator abs is  predefined  for  any  numeric
  1198. type.   The  highest  precedence  unary  operator not is predefined for any
  1199. boolean type and any one-dimensional array type  whose  components  have  a
  1200. boolean type. 
  1201.  
  1202.  Operator   Operation          Operand type                  Result type
  1203.  
  1204.   abs      absolute value     any numeric type              same numeric type
  1205.  
  1206.   not      logical negation   any boolean type              same boolean type
  1207.                               array of boolean components   same array type
  1208.  
  1209. The  operator  not  that  applies  to  a  one-dimensional  array of boolean
  1210. components yields a one-dimensional boolean array  with  the  same  bounds;
  1211. each  component  of  the  result  is  obtained  by  logical negation of the
  1212. corresponding component of the operand (that is, the component that has the
  1213. same index value).                                                    
  1214.  
  1215. The highest precedence exponentiating operator ** is  predefined  for  each
  1216. integer  type  and  for each floating point type.  In either case the right
  1217. operand, called the exponent, is of the predefined type INTEGER. 
  1218.  
  1219.  Operator  Operation      Left operand         Right operand   Result type
  1220.                           type                 type
  1221.  
  1222.    **     exponentiation  any integer type     INTEGER         same as left
  1223.                           any floating point   INTEGER         same as left
  1224.                           type
  1225.  
  1226. Exponentiation  with  a  positive  exponent  is  equivalent   to   repeated
  1227. multiplication  of the left operand by itself, as indicated by the exponent
  1228. and from left to right.  For an operand  of  a  floating  point  type,  the
  1229. exponent  can be negative, in which case the value is the reciprocal of the
  1230. value with the  positive  exponent.   Exponentiation  by  a  zero  exponent
  1231. delivers  the  value  one.   Exponentiation of a value of a floating  point
  1232. type is approximate (see 4.5.7).  Exponentiation of an integer  raises  the  
  1233. exception CONSTRAINT_ERROR for a negative exponent.
  1234.  
  1235. References:   array  type 3.6, boolean type 3.5.3, bound of an array 3.6.1,
  1236. component of an array 3.6, constraint_error exception 11.1,  dimensionality
  1237. 3.6,   floating   point   type   3.5.9,  index  3.6,  integer  type  3.5.4,
  1238. multiplication  operation  4.5.5,  predefined  operator  4.5,  raising   of
  1239. exceptions 11   
  1240.  
  1241. 4.5.7  Accuracy of Operations with Real Operands  
  1242.  
  1243. A  real  subtype  specifies  a  set  of  model  numbers.  Both the accuracy
  1244. required from any basic or predefined operation giving a real  result,  and
  1245. the  result of any predefined relation between real operands are defined in
  1246. terms of these model numbers. 
  1247.  
  1248. A model interval of a subtype  is  any  interval  whose  bounds  are  model
  1249. numbers  of  the  subtype.  The model interval associated with a value that
  1250. belongs to a real subtype is the smallest model interval (of  the  subtype)
  1251. that  includes  the  value.   (The  model  interval associated with a model
  1252. number of a subtype consists of that number only.) 
  1253.  
  1254. For any basic operation or predefined operator that yields a  result  of  a
  1255. real  subtype,  the  required  bounds  on  the  result are given by a model
  1256. interval defined as follows: 
  1257.  
  1258.   -  The result model interval is  the  smallest  model  interval  (of  the
  1259.      result  subtype)  that includes the minimum and the maximum of all the
  1260.      values obtained by applying the (exact) mathematical  operation,  when
  1261.      each  operand is given any value of the model interval (of the operand
  1262.      subtype) defined for the operand. 
  1263.  
  1264.   -  The model interval of an operand that  is  itself  the  result  of  an
  1265.      operation,  other  than  an  implicit  conversion, is the result model
  1266.      interval of this operation.    
  1267.  
  1268.   -  The model interval of an operand whose value is obtained  by  implicit   
  1269.      conversion  of a universal expression is the model interval associated
  1270.      with this value within the operand subtype. 
  1271.  
  1272. The result model interval is undefined if the absolute value of one of  the
  1273. above  mathematical  results  exceeds the largest safe number of the result
  1274. type.  Whenever the result  model  interval  is  undefined,  it  is  highly
  1275. desirable  that the exception NUMERIC_ERROR be raised if the implementation
  1276. cannot produce an actual result that is in the range of safe numbers.  This
  1277. is, however, not required by the language rules, in recognition of the fact
  1278. that certain target machines do  not  permit  easy  detection  of  overflow
  1279. situations.  The value of the attribute MACHINE_OVERFLOWS indicates whether
  1280. the   target   machine  raises  the  exception  NUMERIC_ERROR  in  overflow
  1281. situations (see 13.7.3).                                                            
  1282.  
  1283. The safe numbers of a real type are defined (see 3.5.6) as  a  superset  of
  1284. the  model  numbers,  for  which  error bounds follow the same rules as for
  1285. model numbers.  Any definition given in this  section  in  terms  of  model
  1286. intervals  can  therefore be extended to safe intervals of safe numbers.  A
  1287. consequence of this extension is that an implementation is not  allowed  to
  1288. raise  the  exception  NUMERIC_ERROR  when  the  result  interval is a safe
  1289. interval. 
  1290.  
  1291. For the result of exponentiation, the model interval defining the bounds on
  1292. the result is obtained by applying the  above  rules  to  the  sequence  of
  1293. multiplications  defined  by the exponent, and to the final division in the
  1294. case of a negative exponent. 
  1295.  
  1296. For the result of a relation between two real operands, consider  for  each
  1297. operand  the  model  interval  (of  the  operand  subtype)  defined for the
  1298. operand;  the result can be any value obtained by applying the mathematical
  1299. comparison to values arbitrarily chosen in the corresponding operand  model
  1300. intervals.   If  either or both of the operand model intervals is undefined
  1301. (and if neither of the operand evaluations raises an  exception)  then  the
  1302. result  of  the  comparison  is  allowed to be any possible value (that is,
  1303. either TRUE or FALSE). 
  1304.  
  1305. The result of a membership test is defined in terms of comparisons  of  the
  1306. operand  value  with  the lower and upper bounds of the given range or type
  1307. mark (the usual rules apply to these comparisons).
  1308.  
  1309. Note: 
  1310.  
  1311. For a floating point type the numbers 15.0, 3.0, and 5.0 are  always  model
  1312. numbers.  Hence X/Y where X equals 15.0 and Y equals 3.0 yields exactly 5.0
  1313. according to the above rules.  In the general case, division does not yield
  1314. model numbers and in consequence one cannot assume that (1.0/X)*X = 1.0. 
  1315.  
  1316. References:   attribute 4.1.4, basic operation 3.3.3, bound of a range 3.5,
  1317. error bound 3.5.6, exponentiation  operation  4.5.6,  false  boolean  value
  1318. 3.5.3,  floating  point  type  3.5.9,  machine_overflows  attribute 13.7.1,
  1319. membership test 4.5.2, model number 3.5.6, multiplication operation  4.5.5,
  1320. numeric_error  exception  11.1,  predefined  operation  3.3.3,  raising  of
  1321. exceptions 11,  range  3.5,  real  type  3.5.6,  relation  4.4,  relational
  1322. operator  4.5.2  4.5,  safe  number  3.5.6, subtype 3.3, true boolean value
  1323. 3.5.3, type conversion 4.6, type mark 3.3.2, universal expression 4.1 4  
  1324.  
  1325. 4.6  Type Conversions  
  1326.  
  1327. The evaluation of an  explicit type  conversion  evaluates  the  expression
  1328. given  as  the  operand,  and  converts  the resulting value to a specified
  1329. target type.  Explicit type conversions are allowed between closely related
  1330. types as defined below. 
  1331.  
  1332.     type_conversion ::= type_mark(expression)    
  1333.  
  1334. The target type of a type conversion is the base type  of  the  type  mark.
  1335. The  type  of  the  operand  of  a  type  conversion  must  be determinable
  1336. independently of the context (in particular, independently  of  the  target
  1337. type).   Furthermore, the operand of a type conversion is not allowed to be
  1338. a literal null, an allocator,  an  aggregate,  or  a  string  literal;   an
  1339. expression  enclosed  by  parentheses  is  allowed as the operand of a type
  1340. conversion only if the expression alone is allowed. 
  1341.  
  1342. A conversion to a subtype consists of  a  conversion  to  the  target  type
  1343. followed  by  a  check  that  the  result  of the conversion belongs to the
  1344. subtype.  A conversion of an operand of a given type to the type itself  is
  1345. allowed.                                                                                   
  1346.  
  1347. The  other  allowed  explicit  type conversions correspond to the following
  1348. three cases: 
  1349.  
  1350. (a)  Numeric types 
  1351.  
  1352.      The operand can be of any numeric type;  the value of the  operand  is
  1353.      converted  to  the target type which must also be a numeric type.  For
  1354.      conversions involving real types, the result is within the accuracy of
  1355.      the specified subtype (see 4.5.7).  The conversion of a real value  to
  1356.      an  integer  type  rounds  to  the nearest integer;  if the operand is
  1357.      halfway between two integers (within the accuracy of the real subtype)
  1358.      rounding may be either up or down. 
  1359.  
  1360. (b)  Derived types 
  1361.  
  1362.      The conversion is allowed if one of the target type  and  the  operand
  1363.      type  is  derived  from the other, directly or indirectly, or if there
  1364.      exists a third type from which both types  are  derived,  directly  or
  1365.      indirectly. 
  1366.  
  1367. (c)  Array types  
  1368.  
  1369.      The  conversion is allowed if the operand type and the target type are
  1370.      array types that satisfy the following conditions:   both  types  must
  1371.      have the same dimensionality;  for each index position the index types
  1372.      must  either  be  the  same  or  be  convertible  to  each other;  the
  1373.      component types must be the same;  finally, if the component type is a
  1374.      type with discriminants or an access type, the component subtypes must
  1375.      be either both constrained or both unconstrained.  If  the  type  mark
  1376.      denotes  an  unconstrained  array type, then, for each index position,
  1377.      the bounds of the result are obtained by converting the bounds of  the
  1378.      operand  to  the  corresponding index type of the target type.  If the
  1379.      type mark denotes a constrained array subtype, then the bounds of  the
  1380.      result  are those imposed by the type mark.  In either case, the value
  1381.      of each component of the result is that of the matching  component  of
  1382.      the operand (see 4.5.2). 
  1383.  
  1384. In  the  case  of  conversions  of  numeric  types  and  derived types, the
  1385. exception CONSTRAINT_ERROR is raised by the evaluation of a type conversion
  1386. if the result of the conversion fails to satisfy a  constraint  imposed  by
  1387. the type mark. 
  1388.  
  1389. In  the  case  of  array  types, a check is made that any constraint on the
  1390. component subtype is the same for the operand array type as for the  target
  1391. array  type.   If  the type mark denotes an unconstrained array type and if
  1392. the operand is not a null array, then, for each index position, a check  is
  1393. made  that  the  bounds  of  the  result  belong to the corresponding index
  1394. subtype of the target type.  If the type mark denotes a  constrained  array
  1395. subtype,  a check is made that for each component of the operand there is a
  1396. matching component of the target subtype, and vice  versa.   The  exception
  1397. CONSTRAINT_ERROR is raised if any of these checks fails.  
  1398.  
  1399. If a conversion is allowed from one type to another, the reverse conversion
  1400. is  also allowed. This reverse conversion is used where an actual parameter
  1401. of mode in out or out has the form of a type  conversion  of  a  (variable)  
  1402. name as explained in section 6.4.1. 
  1403.  
  1404. Apart  from  the  explicit  type conversions, the only allowed form of type
  1405. conversion  is  the  implicit  conversion  of   a   value   of   the   type
  1406. universal_integer or universal_real into another numeric type.  An implicit
  1407. conversion of an operand of type universal_integer to another integer type,
  1408. or  of  an operand of type universal_real to another real type, can only be
  1409. applied if the operand is either a numeric literal, a named number,  or  an
  1410. attribute;   such  an  operand is called a convertible universal operand in
  1411. this section.  An implicit conversion of a convertible universal operand is
  1412. applied if and only if the innermost complete context (see 8.7)  determines
  1413. a unique (numeric) target type for the implicit conversion, and there is no
  1414. legal interpretation of this context without this conversion.                                            
  1415.  
  1416. Notes: 
  1417.  
  1418. The  rules  for  implicit  conversions imply that no implicit conversion is
  1419. ever applied to the operand of an  explicit  type  conversion.   Similarly,
  1420. implicit  conversions  are  not  applied  if  both operands of a predefined
  1421. relational operator are convertible universal operands. 
  1422.  
  1423. The language allows implicit subtype conversions in the case of array types
  1424. (see 5.2.1).  An explicit type conversion can have the effect of  a  change
  1425. of  representation (in particular see 13.6).  Explicit conversions are also  
  1426. used for actual parameters (see 6.4). 
  1427.  
  1428. Examples of numeric type conversion: 
  1429.  
  1430.     REAL(2*J)      --  value is converted to floating point
  1431.     INTEGER(1.6)   --  value is 2
  1432.     INTEGER(-0.4)  --  value is 0
  1433.  
  1434. Example of conversion between derived types: 
  1435.  
  1436.     type A_FORM is new B_FORM; 
  1437.  
  1438.     X : A_FORM;
  1439.     Y : B_FORM; 
  1440.  
  1441.     X := A_FORM(Y);
  1442.     Y := B_FORM(X);  --  the reverse conversion 
  1443.  
  1444. Examples of conversions between array types: 
  1445.  
  1446.     type SEQUENCE is array (INTEGER range <>) of INTEGER;
  1447.     subtype DOZEN is SEQUENCE(1 .. 12);
  1448.     LEDGER : array(1 .. 100) of INTEGER;
  1449.  
  1450.     SEQUENCE(LEDGER)            --  bounds are those of LEDGER
  1451.     SEQUENCE(LEDGER(31 .. 42))  --  bounds are 31 and 42
  1452.     DOZEN(LEDGER(31 .. 42))     --  bounds are those of DOZEN 
  1453.  
  1454. Examples of implicit conversions: 
  1455.  
  1456.     X : INTEGER := 2; 
  1457.  
  1458.     X + 1 + 2              -- implicit conversion of each integer literal
  1459.     1 + 2 + X              -- implicit conversion of each integer literal
  1460.     X + (1 + 2)            -- implicit conversion of each integer literal 
  1461.  
  1462.     2 = (1 + 1)            -- no implicit conversion:  the type is uni-
  1463.                               versal_integer
  1464.     A'LENGTH = B'LENGTH    -- no implicit conversion:  the type is uni-
  1465.                               versal_integer
  1466.     C : constant := 3 + 2; -- no implicit conversion:  the type is uni-
  1467.                               versal_integer
  1468.  
  1469.     X = 3 and 1 = 2        -- implicit conversion of 3, but not of 1 and 2 
  1470.  
  1471. References:  actual parameter 6.4.1, array type 3.6, attribute 4.1.4,  base
  1472. type 3.3, belong to a subtype 3.3, component 3.3, constrained array subtype
  1473. 3.6,  constraint_error  exception  11.1,  derived  type 3.4, dimension 3.6,  
  1474. expression 4.4, floating point type 3.5.7, index 3.6,  index  subtype  3.6,
  1475. index  type  3.6,  integer  type 3.5.4, matching component 4.5.2, mode 6.1,   
  1476. name 4.1, named number 3.2, null array 3.6.1, numeric literal 2.4,  numeric
  1477. type  3.5,  raising of exceptions 11, real type 3.5.6, representation 13.1,
  1478. statement 5, subtype 3.3, type 3.3, type mark  3.3.2,  unconstrained  array
  1479. type 3.6, universal_integer type 3.5.4, universal_real type 3.5.6, variable 
  1480. 3.2.1                                                                                      
  1481.  
  1482. 4.7  Qualified Expressions  
  1483.  
  1484. A  qualified  expression is used to state explicitly the type, and possibly
  1485. the subtype, of an operand that is the given expression or aggregate. 
  1486.  
  1487.     qualified_expression ::=
  1488.        type_mark'(expression) | type_mark'aggregate 
  1489.  
  1490. The operand must have the same type as the base type of the type mark.  The
  1491. value of  a  qualified  expression  is  the  value  of  the  operand.   The
  1492. evaluation  of a qualified expression evaluates the operand and checks that
  1493. its value belongs to the subtype denoted by the type mark.   The  exception
  1494. CONSTRAINT_ERROR is raised if this check fails. 
  1495.  
  1496. Examples: 
  1497.  
  1498.     type MASK is (FIX, DEC, EXP, SIGNIF);
  1499.     type CODE is (FIX, CLA, DEC, TNZ, SUB); 
  1500.  
  1501.     PRINT (MASK'(DEC));  --  DEC is of type MASK
  1502.     PRINT (CODE'(DEC));  --  DEC is of type CODE 
  1503.  
  1504.     for J in CODE'(FIX) .. CODE'(DEC) loop ... -- qualification needed for
  1505.                                                   either FIX or DEC
  1506.     for J in CODE range FIX .. DEC loop ...    -- qualification unnecessary
  1507.     for J in CODE'(FIX) .. DEC loop ...        -- qualification unnecessary
  1508.                                                   for DEC
  1509.  
  1510.     DOZEN'(1 | 3 | 5 | 7 => 2, others => 0) -- see 4.6 
  1511.  
  1512. Notes: 
  1513.  
  1514. Whenever  the type of an enumeration literal or aggregate is not known from
  1515. the context,  a  qualified  expression  can  be  used  to  state  the  type  
  1516. explicitly.   For  example,  an  overloaded  enumeration  literal  must  be
  1517. qualified in the  following  cases:   when  given  as  a  parameter   in  a
  1518. subprogram  call  to  an  overloaded  subprogram  that  cannot otherwise be
  1519. identified on the basis of  remaining  parameter  or  result  types,  in  a
  1520. relational  expression  where  both  operands  are  overloaded  enumeration
  1521. literals, or in an array or loop parameter  range  where  both  bounds  are
  1522. overloaded  enumeration  literals.   Explicit qualification is also used to
  1523. specify which one of a set of overloaded parameterless functions is  meant,
  1524. or to constrain a value to a given subtype. 
  1525.  
  1526. References:  aggregate 4.3, array 3.6, base type 3.3, bound of a range 3.5,
  1527. constraint_error  exception  11.1,  context  of  overload  resolution  8.7,
  1528. enumeration literal 3.5.1, expression 4.4,  function  6.5,  loop  parameter
  1529. 5.5,  overloading  8.5,  raising of exceptions 11, range 3.3, relation 4.4,
  1530. subprogram 6, subprogram call 6.4, subtype 3.3, type 3.3, type mark 3.3.2   
  1531.  
  1532. 4.8  Allocators     
  1533.  
  1534. The evaluation of an allocator creates an object and yields an access value
  1535. that designates the object. 
  1536.  
  1537.     allocator ::=
  1538.        new subtype_indication | new qualified_expression                                                    
  1539.  
  1540. The type of the object created by an allocator is the base type of the type
  1541. mark given in either the subtype indication or  the  qualified  expression.
  1542. For  an  allocator with a qualified expression, this expression defines the
  1543. initial value of the created object.  The type of the access value returned  
  1544. by an allocator must be determinable solely from the context, but using the
  1545. fact that the value  returned  is  of  an  access  type  having  the  named
  1546. designated type. 
  1547.  
  1548. The  only  allowed  forms  of  constraint  in  the subtype indication of an
  1549. allocator are index and discriminant constraints.  If an allocator includes
  1550. a subtype indication and if the type of the object created is an array type
  1551. or a type with discriminants that do not have default expressions, then the
  1552. subtype indication must either denote a constrained subtype, or include  an
  1553. explicit index or discriminant constraint. 
  1554.  
  1555. If  the  type  of  the  created  object  is  an  array  type or a type with
  1556. discriminants, then the created  object  is  always  constrained.   If  the
  1557. allocator  includes a subtype indication, the created object is constrained
  1558. either by the subtype or  by  the  default  discriminant  values.   If  the
  1559. allocator   includes   a   qualified  expression,  the  created  object  is
  1560. constrained by the bounds or discriminants of the initial value.  For other
  1561. types, the subtype of the created object is  the  subtype  defined  by  the
  1562. subtype indication of the access type definition. 
  1563.  
  1564. For  the  evaluation  of  an  allocator,  the  elaboration  of  the subtype
  1565. indication or the evaluation  of  the  qualified  expression  is  performed
  1566. first.  The new object is then created.  Initializations are then performed
  1567. as  for  a  declared  object (see 3.2.1);  the initialization is considered
  1568. explicit in the case of a qualified expression;   any  initializations  are
  1569. implicit  in  the  case  of a subtype indication.  Finally, an access value
  1570. that designates the created object is returned. 
  1571.  
  1572. An implementation must guarantee that any object created by the  evaluation
  1573. of  an allocator remains allocated for as long as this object or one of its
  1574. subcomponents is accessible directly or indirectly, that is, as long as  it 
  1575. can  be  denoted  by  some  name.   Moreover,  if  an  object or one of its
  1576. subcomponents belongs to a task type, it is considered to be accessible  as
  1577. long  as  the task is not terminated.  An implementation may (but need not)
  1578. reclaim the storage occupied by an object created  by  an  allocator,  once
  1579. this object has become inaccessible. 
  1580.  
  1581. When  an  application  needs  closer  control  over  storage allocation for
  1582. objects designated by values  of  an  access  type,  such  control  may  be
  1583. achieved by one or more of the following means: 
  1584.  
  1585. (a)  The total amount of storage available for the collection of objects of
  1586.      an access type can be set by means of a length clause (see 13.2). 
  1587.  
  1588. (b)  The  pragma  CONTROLLED  informs  the  implementation  that  automatic
  1589.      storage  reclamation  must  not be performed for objects designated by
  1590.      values of the access type, except upon  leaving  the  innermost  block
  1591.      statement, subprogram body, or task body that encloses the access type
  1592.      declaration, or after leaving the main program.    
  1593.  
  1594.         pragma CONTROLLED (access_type_simple_name); 
  1595.  
  1596.      A  pragma  CONTROLLED  for  a given access type is allowed at the same
  1597.      places as a representation clause  for  the  type  (see  13.1).   This
  1598.      pragma is not allowed for a derived type. 
  1599.  
  1600. (c)  The explicit deallocation of the object designated by an access  value
  1601.      can  be  achieved  by calling a procedure obtained by instantiation of
  1602.      the predefined generic library procedure  UNCHECKED_DEALLOCATION  (see
  1603.      13.10.1). 
  1604.  
  1605. The  exception  STORAGE_ERROR  is  raised  by  an allocator if there is not
  1606. enough storage.  Note also  that  the  exception  CONSTRAINT_ERROR  can  be
  1607. raised by the evaluation of the qualified expression, by the elaboration of
  1608. the subtype indication, or by the initialization.                                           
  1609.  
  1610. Examples (for access types declared in section 3.8):  
  1611.  
  1612.  new CELL'(0, null, null)                          -- initialized explicitly
  1613.  new CELL'(VALUE => 0, SUCC => null, PRED => null) -- initialized explicitly
  1614.  new CELL                                          -- not initialized
  1615.  
  1616.  new MATRIX(1 .. 10, 1 .. 20)                  -- the bounds only are given
  1617.  new MATRIX'(1 .. 10 => (1 .. 20 => 0.0))      -- initialized explicitly
  1618.  
  1619.  new BUFFER(100)                          -- the discriminant only is given
  1620.  
  1621.  new BUFFER'(SIZE => 80, POS => 0, VALUE => (1 .. 80 => 'A'))
  1622.                                                -- initialized explicitly
  1623.  
  1624. References:  access type 3.8, access type definition 3.8, access value 3.8,
  1625. array  type  3.6,  block statement 5.6, bound of an array 3.6.1, collection
  1626. 3.8, constrained subtype 3.3, constraint  3.3,  constraint_error  exception
  1627. 11.1,  context of overload resolution 8.7, derived type 3.4, designate 3.8,
  1628. discriminant  3.3,  discriminant   constraint   3.7.2,   elaboration   3.9,
  1629. evaluation  of  a  qualified  expression 4.7, generic procedure 12.1, index
  1630. constraint 3.6.1, initial value 3.2.1, initialization 3.2.1,  instantiation
  1631. 12.3,  length  clause 13.2, library unit 10.1, main program 10.1, name 4.1,
  1632. object 3.2.1, object declaration 3.2.1, pragma 2.8, procedure 6,  qualified
  1633. expression  4.7,  raising  of  exceptions  11,  representation clause 13.1,
  1634. simple name 4.1, storage_error exception 11.1, subcomponent 3.3, subprogram
  1635. body 6.3, subtype 3.3, subtype indication 3.3.2, task body 9.1,  task  type
  1636. 9.2, terminated task 9.4, type 3.3, type declaration 3.3.1, type mark 3.3.2
  1637. type with discriminants 3.3   
  1638.  
  1639. 4.9  Static Expressions and Static Subtypes     
  1640.  
  1641. Certain  expressions  of  a  scalar type are said to be static.  Similarly,
  1642. certain discrete ranges are said to  be  static,  and  the  type  marks  of
  1643. certain scalar subtypes are said to denote static subtypes. 
  1644.  
  1645. An  expression  of  a scalar type is said to be static if and only if every
  1646. primary is one of those listed in (a) through  (h)  below,  every  operator
  1647. denotes  a  predefined  operator,  and  the  evaluation  of  the expression
  1648. delivers a value (that is, it does not raise an exception): 
  1649.  
  1650. (a)  An enumeration literal (including a character literal). 
  1651.  
  1652. (b)  A numeric literal. 
  1653.  
  1654. (c)  A named number. 
  1655.  
  1656. (d)  A constant explicitly declared by a constant declaration with a static
  1657.      subtype, and initialized with a static expression. 
  1658.  
  1659. (e)  A function call whose function name is an operator symbol that denotes
  1660.      a predefined operator, including a function name that is  an  expanded
  1661.      name;  each actual parameter must also be a static expression.  
  1662.  
  1663. (f)  A language-defined attribute of a static subtype;   for  an  attribute
  1664.      that  is  a  function,  the  actual  parameter  must  also be a static
  1665.      expression.                                                      
  1666.  
  1667. (g)  A qualified expression whose type mark denotes a  static  subtype  and
  1668.      whose operand is a static expression. 
  1669.  
  1670. (h)  A static expression enclosed in parentheses. 
  1671.  
  1672. A  static  range  is a range whose bounds are static expressions.  A static
  1673. range constraint is a range constraint whose range  is  static.   A  static
  1674. subtype is either a scalar base type, other than a generic formal type;  or
  1675. a  scalar  subtype  formed  by imposing on a static subtype either a static
  1676. range constraint, or a floating  or  fixed  point  constraint  whose  range
  1677. constraint,  if any, is static.  A static discrete range is either a static
  1678. subtype or  a  static  range.   A  static  index  constraint  is  an  index
  1679. constraint  for which each index subtype of the corresponding array type is
  1680. static, and in which each discrete range is static.  A static  discriminant
  1681. constraint  is  a  discriminant  constraint  for  which the subtype of each
  1682. discriminant is static, and in which each expression is static. 
  1683.  
  1684. Notes: 
  1685.  
  1686. The accuracy of the evaluation of a static expression having a real type is
  1687. defined by the rules given in section 4.5.7.  If the result is not a  model
  1688. number  (or  a  safe  number)  of  the  type,  the  value  obtained by this
  1689. evaluation at compilation time need not be the same as the value that would
  1690. be obtained by an evaluation at run time. 
  1691.  
  1692. Array attributes are not static:  in particular, the RANGE attribute is not
  1693. static. 
  1694.  
  1695. References:  actual parameter 6.4.1, attribute 4.1.4, base type 3.3,  bound
  1696. of a range 3.5, character literal 2.5, constant 3.2.1, constant declaration
  1697. 3.2.1,  discrete  range  3.6, discrete type 3.5, enumeration literal 3.5.1,
  1698. exception 11, expression 4.4, function 6.5, generic actual parameter  12.3,
  1699. generic  formal  type  12.1.2,  implicit declaration 3.1, initialize 3.2.1,
  1700. model number 3.5.6, named  number  3.2,  numeric  literal  2.4,  predefined
  1701. operator  4.5,  qualified  expression  4.7, raising of exceptions 11, range
  1702. constraint 3.5, safe number 3.5.6, scalar type 3.5, subtype 3.3, type  mark
  1703. 3.3.2   
  1704.  
  1705. 4.10  Universal Expressions  
  1706.  
  1707. A  universal_expression  is  either an expression that delivers a result of
  1708. type  universal_integer  or  one   that   delivers   a   result   of   type
  1709. universal_real.   
  1710.  
  1711. The  same  operations  are predefined for the type universal_integer as for
  1712. any integer  type.   The  same  operations  are  predefined  for  the  type
  1713. universal_real  as  for  any  floating  point  type.   In  addition,  these
  1714. operations include the following multiplication and division operators: 
  1715.  
  1716. Operator  Operation  Left operand       Right operand       Result type
  1717.                      type               type
  1718.  
  1719.    *      multiply   universal_real     universal_integer   universal_real
  1720.                      universal_integer  universal_real      universal_real
  1721.  
  1722.    /      divide     universal_real     universal_integer   universal_real
  1723.  
  1724. The  accuracy  of  the  evaluation  of  a  universal  expression  of   type
  1725. universal_real  is at least as good as that of the most accurate predefined
  1726. floating  point  type  supported  by   the   implementation,   apart   from
  1727. universal_real  itself.  Furthermore, if a universal expression is a static
  1728. expression, then the evaluation must be exact.                                               
  1729.  
  1730. For the evaluation of an operation of a nonstatic universal expression,  an
  1731. implementation  is allowed to raise the exception NUMERIC_ERROR only if the
  1732. result of the operation is a real value whose absolute  value  exceeds  the
  1733. largest  safe  number  of  the most accurate predefined floating point type
  1734. (excluding universal_real), or an integer value greater than SYSTEM.MAX_INT
  1735. or less than SYSTEM.MIN_INT.
  1736.  
  1737. Note: 
  1738.  
  1739. It is a consequence of the  above  rules  that  the  type  of  a  universal
  1740. expression   is   universal_integer  if  every  primary  contained  in  the   
  1741. expression is of this type (excluding actual parameters of attributes  that
  1742. are  functions,  and  excluding right operands of exponentiation operators)
  1743. and that otherwise the type is universal_real. 
  1744.  
  1745. Examples: 
  1746.  
  1747.     1 + 1       -- 2
  1748.     abs(-10)*3  -- 30
  1749.  
  1750.     KILO : constant := 1000;
  1751.     MEGA : constant := KILO*KILO;   -- 1_000_000
  1752.     LONG : constant := FLOAT'DIGITS*2;
  1753.  
  1754.     HALF_PI    : constant := PI/2;           -- see 3.2.2
  1755.     DEG_TO_RAD : constant := HALF_PI/90;
  1756.     RAD_TO_DEG : constant := 1.0/DEG_TO_RAD; -- equivalent to
  1757.                                                 1.0/((3.14159_26536/2)/90)
  1758.  
  1759. References:  actual parameter 6.4.1,  attribute  4.1.4,  evaluation  of  an
  1760. expression  4.5,  floating  point  type  3.5.9,  function 6.5, integer type
  1761. 3.5.4, multiplying operator 4.5 4.5.5, predefined operation 3.3.3,  primary
  1762. 4.4,   real   type   3.5.6,   safe   number   3.5.6,  system.max_int  13.7,
  1763. system.min_int 13.7, type 3.3, universal_integer type 3.5.4, universal_real
  1764. type 3.5.6                                                                                       
  1765.