J3/01-157 Date: 3 March 2001 To: J3 From: John Reid Subject: Interpretation 22 (Use of NULL() as initialization) Here is a draft answer for interp. 22. As far as I know, this is the first attempt at a response to this one. I sent earlier drafts to the WG5 list for comments and would like thank Malcolm Cohen for the improvements that he suggested. .............................................................. NUMBER: 000022 TITLE: Use of NULL() as initialization KEYWORDS: NULL intrinsic, initialization, default initialization, DATA statement DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Rules R429, R505 and R540 respectively describe the syntax for default initialization of pointer components, pointer objects in type declaration statements and pointer objects in DATA statements. These rules seem to indicate that NULL is to be considered a keyword in those contexts. This has the surprising effect that the first example below is a standard conforming program, while the second is not. That is, in some contexts, something that looks very much like a reference to an intrinsic function, is in fact a keyword followed by parentheses. Example 1: MODULE MOD INTRINSIC NULL END MODULE MOD PROGRAM PROG USE MOD, DISASSOCIATE=>NULL INTEGER, PARAMETER :: NULL = 17 INTEGER :: J = NULL INTEGER :: I INTEGER, POINTER :: P => NULL(), P2 DATA P2, I/NULL(), NULL/ TYPE DT INTEGER, POINTER :: P => NULL() END TYPE DT TYPE DT2 INTEGER, POINTER :: I INTEGER :: J END TYPE DT2 TYPE(DT2) :: S = DT2(DISASSOCIATE(), NULL), S2 DATA S2/DT2(DISASSOCIATE(), NULL)/ END PROGRAM PROG Example 2: MODULE MOD INTRINSIC NULL END MODULE MOD PROGRAM PROG USE MOD, DISASSOCIATE=>NULL INTEGER, POINTER :: P => DISASSOCIATE(), P2 DATA P2/DISASSOCIATE()/ TYPE DT INTEGER, POINTER :: P => DISASSOCIATE() END TYPE DT END PROGRAM PROG In some places in the scoping unit of PROG example 1, NULL() is used to specify initialization or default initialization, while in others NULL is a named constant, and DISASSOCIATE() must be used to specify initialization. 1) Is example 1 a standard conforming program? 2) Is example 2 a standard conforming program? 3) Was it the intent of the committee that, within the contexts of R429, R505 and R540, NULL should be treated strictly as a keyword rather than as a reference to an intrinsic function? DISCUSSION: The intention is that the intrinsic function NULL be referenced with no arguments in initialization contexts. This is made clear in the middle of page 49 in the paragraph that begins 'If ' [49:20-21] and also in 7.1.4.1. If the intrinsic function has been renamed, the new name should be used. ANSWER: (1) No, the example is not conforming because it references two different entities with the same name (NULL the local variable, and NULL the intrinsic function). See 14.1.2. (2) No, the example does not conform to the standard as published. This is an error, corrected by the supplied edits which make this example conforming. (3) No, the intention was that "NULL()" should be a reference to the intrinsic function. Edits are supplied to remove the keyword status of this syntax. EDITS: Page 39, subclause 4.4.1, replace the second line of R429 [39:20] by <> => R429a <> Constraint: shall be a reference to the intrinsic function NULL with no arguments. Page 47, subclause 5.1, replace the second line of R505 [47:40] by <> => Page 49, subclause 5.1, in the paragraph that begins 'If ' [49:20-21], replace 'NULL()' by '' twice. Page 62, subclause 5.2.10, replace the fifth line of R540 [62:19] by <> Page 62, subclause 5.2.10, in the penultimate line of the page [62:48], replace 'NULL()' by 'pointer association status'. Page 63, subclause 5.2.10, in lines 1, 7 and 10 of the page [63:1,7,10], replace 'NULL()' by '' thrice. SUBMITTED BY: Henry Zongaro HISTORY: 98-151 m145 Submitted