J3/13-353 To: J3 From: Van Snyder Subject: Initializing variables that have default initialization Date: 2013 October 14 Reference: Interpretation F08/0062 Title: Initializing variables that have default initialization Submitted by: Van Snyder Status: For consideration Basic functionality: Allow variables of types that have default initialization to be initialized in DATA statements. Whether to continue to prohibit initializing a subcomponent of a variable of a type that has default initialization can be decided in due course. Rationale: Variables that have default initialization can be explicitly initialized in type declaration statements. For consistency, it would be useful to allow such variables to be initialized in DATA statements. Initializing large arrays of such variables in type declaration statements is tedious if the initialization does not fit within the statement length limit. Where one desires to initialize some elements of an array using explicit initialization, while other elements have default-initialized values, it would be useful to allow elements of arrays of such types to be initialized in DATA statements. This is not possible in a type declaration statement. Otherwise, one needs either to initialize the entire array in a type declaration statement, using named constants if needed to cope with statement length limitations, or to leave the array default initialized rather than explicitly initialized, provide a procedure that initializes the desired elements by assignment, and take care that this procedure is invoked at the appropriate time. Some processors allow initializing such variables in DATA statements as a convenient extension, silently ignoring the non-constraint prohibition in the second paragraph of subclause 5.4.7. This can cause delayed and sometimes expensive portability surprises. Either initialization in DATA statements should be allowed, or the prohibition against it should be a constraint. The former would be more useful. Estimated impact: Minor Markham M6 conformance: Remove simple deficiency and discrepancy. Detailed specification: Allow a variable of a type that has default initialization to be initialized in a DATA statement. Allow an element of an array of a type that has default initialization to be initialized in a DATA statement. Whether it is desired to continue to prohibit initializing a subcomponent of a variable of a type that has default initialization can be decided in due course. Draft edits (to estimate scope of the project): Within a list in a new subclause of subclause 1.6 that describes new features, include an item: o It is possible, in a DATA statement, to initialize a variable of a type that has default initialization. Delete Paragraph 2 of subclause 5.4.7 [104:7]. If it is desired to continue to prohibit initializing a subcomponent of a variable of a type that has default initialization: Introduce a constraint in subclause 5.4.7: "C567a (R536) The shall not be a subcomponent of a variable that has default initialization." Revise C569: "C569 (R538) The shall be a variable that is not a subcomponent of a variable that has default initialization." Replace C570: "C570 (R538) The shall be a variable that is not a subcomponent of a variable that has default initialization."