Subject: Edits for Nagging Doubt I J3/03-231 From: Kurt W. Hirchert (Meeting 165) 14 Aug 2003 The problem to be addressed by these is described in the original "Nagging Doubts" document, ISO/IEC JTC1/SC22/WG5/N1558. All edits are expressed relative to J3/03-007. ======= Edits A ======= Undo (most of) the effects of J3/03-118r3: 1. 34:25 Change "an intrinsic" to "a derived-type intrinsic". 2. 141:2-3 Change "Either ... or the" to "The". 3. 141:5+7 Remove "kind" and ";". 141:5+8-10 Remove. 4. 141:25-142:1-1 Remove. 5. 142:5+5-9 Remove. ======= Edits B ======= Makes functionality available as a new statement: 1. 11:6 Replace "" with "\n <> " 2. 25:4 Insert ":=, " into list after ":, ". 3. 34:25 After "(7.4.1.3), ", insert "execution of an allocating assignment statement (7.4.1+1), ". 4. 145:5- Insert new subsection: " 7.4.1+1 Allocating assignment Allocating assignment causes an allocatable variable to be allocated with appropriate bounds and length type parameters before defining the variable as by an assignment statement (7.4.1). R734+1 <> := C715+1 (R734+1) shall be allocatable. C715+2 (R734+1) If is polymorphic, it shall be type compatible with . C715+3 (R734+1) and shall have the same rank. C715+4 (R734+1) For each deferred length parameter of , the type of shall have a type parameter of the same name. C715+5 (R734+1) The type, kind type, parameters, and rank of and shall be such that the assignment = is defined. Execution of the allocating assignment statement causes the following to occur: (1) and any expressions necessary to identify are evaluated. If references , it references the state of as it is immediately prior to execution of the statement. (2) If is allocated prior to execution of the statement, that old allocation is deallocated. (3) is allocated as follows: (a) If is polymorphic, it is allocated with the dynamic type and type parameters of ; otherwise, only its deferred length type parameters are not fixed, and the value of each such type parameter is taken from the value of the type parameter with the same name from the type of . (b) For each dimension of , its bounds are taken from the value of the LBOUND and UBOUND intrinsic functions applied to the corresponding dimension of . (4) The value of is assigned to the newly allocated as if by the assignment statement = . A processor may vary the order of these steps. Note 7.41+1 For example, if the expression is such that its bounds and type parameter values can be determined without full evaluation, a processor might do new allocation first, combine evaluation of the expression and its assignment to the variable, and dispose of the old allocation last. Note 7.41+2 For example, given the declaration CHARACTER(:),ALLOCATABLE :: NAME then after the allocating assignment statement NAME := 'Dr. '//FIRST_NAME//' '//SURNAME NAME will have the length LEN(FIRST_NAME)+LEN(SURNAME)+5, regardless of its previous allocation status. In contrast, for the ordinary assignment statement NAME = 'Dr. '//FIRST_NAME//' '//SURNAME NAME must already be allocated, and the assigned value is padded or truncated to match the previously allocated length of NAME. If C is an allocatable array of rank 1, then C := PACK(ARRAY,ARRAY>0) will cause C to contain all the positive elements of ARRAY in array element order, regardless of its previous allocation status. " ======= Edits C ======= Describe the handling of allocatable components in intrinsic assignment in terms of allocating assignment: 1. 143:15-25 Replace "using pointer assignment ... component otherwise." with ": (1) For each nonpointer nonallocatable component, defined assignment is used if the component is of a type that has a type-bound defined assignment consistent with the component, and intrinsic assignment is used otherwise. (2) For each pointer component, pointer assignment (7.4.2) is used. (3) For each allocatable component, allocating assignment (7.4.1+1) is used, with the underlying assignment being defined assignment if the component is of a type that has a type-bound defined assignment consistent with the component and intrinsic assignment otherwise." - end -