Renaming a slice AI-00170/07 1 88-06-13 BI WJ | !standard 08.05 (05) 88-06-13 AI-00170/07 !class binding interpretation 84-01-17 | !status approved by WG9/AJPO 88-02-05 (corrected in accordance with AI-00502) | !status approved by WG9/AJPO 86-07-22 !status approved by Director, AJPO 86-07-22 !status approved by WG9/Ada Board 86-07-22 !status approved by Ada Board 86-07-22 !status approved by WG9 86-05-09 !status committee-approved (8-0-0) 86-02-20 !status work-item 86-01-17 !status received 84-01-17 | !references 83-00257, 83-00859 !topic Renaming a slice !summary 86-01-17 A slice must not be renamed if renaming is prohibited for any of its components. | !question 88-06-13 4.1.2(1) says that: A slice denotes a one-dimensional array formed by a sequence of consecutive components of a one-dimensional array. and 8.5(5) says that: The following restrictions apply to the renaming of a subcomponent that depends on discriminants of a variable. ... A strict reading of 4.1.2 indicates that a slice is not an example of a component -- it is, instead, a one-dimensional array, which is apparently an entirely separate concept. If so, then apparently the restrictions in 8.5(5) about renaming a subcomponent that depends on a discriminant do not apply to slices. For example: | type SINT is NATURAL range 0..100; type VREC (N : SINT := 0) is record S : STRING (1..N); end record; OBJ : VREC := (3, "ABC"); OBJ1 : CHARACTER renames OBJ.S(1); -- illegal by 8.5(5) OBJ2 : STRING renames OBJ.S(1..2); -- illegal? (yes) OBJ.S(1..2) is a slice and thus not clearly a "component", so 8.5(5) does not clearly apply. Do the restrictions of 8.5(5) apply to slices as well as "just subcomponents"? Renaming a slice AI-00170/07 2 88-06-13 BI WJ !recommendation 86-01-17 A slice must not be renamed if renaming is prohibited for any of its components. !discussion 86-03-05 The reason for the restrictions in 8.5(5) is to prevent the newly declared name from denoting an object whose existence may subsequently cease while execution is still within the scope of the name. In the example, a subsequent assignment OBJ := (0, ""); would cause OBJ1 to denote a no-longer existing object, namely, OBJ.S(1). Similarly, OBJ2 would now denote a non-existent array object, namely, OBJ.S(1..2). This undesirable situation was not intended.