J3/97-238 Date: 15 October 1997 To: J3 From: Larry Rolison Subject: Interpretation Request: Free source form requirement for blank in PRINT statement NUMBER: 2 TITLE: Free source form requirement for blank in PRINT statement KEYWORDS: free source form, PRINT, blank DEFECT TYPE: Interpretation STATUS: X3J3 consideration in progress QUESTION: Consider the following PRINT statement form: PRINT"(I5)",5 Section 3.3.1 of the Fortran 95 standard states: A blank shall be used to separate names, constants, or labels from adjacent keywords, names, constants, or labels. NOTE 3.3 For example, the blank[s] after ... READ ... [is] required in the following: ... READ 10 ... Although the sentence preceding R420 is somewhat confusing in that it uses the phrase "a sequence of characters, DELIMITED by either apostrophes or quotation marks", the syntax rule itself is clear that the " or ' delimiting characters are part of the syntax. The first sentence on the top of page 36 then clarifies that although the delimiter characters are a part of the syntax, they are not a part of the value. Section 3.2 makes it clear that a character literal constant is a token. Section 3.2.5 describes delimiters but does not include either " or ' because it is describing delimiters for lists. Thus, it seems clear that in free source form a blank is required between the keyword PRINT and the character literal constant containing the format list but there is also some disagreement on this point among existing Fortran processors. (1) In free source form, is a blank required between the keyword PRINT and the character literal constant containing the format specification? (2) Also, for clarification, in free source form, is a blank required between the keyword PRINT and the asterisk that represents the unformatted output specifier? ANSWER: EDITS: SUBMITTED BY: Larry Rolison / Dick Hendrickson HISTORY: J3/97-238 m143 submitted Addendum: The original email message posted by Dick Hendrickson and some email reactions to the question when it was posted to the J3 reflector: Date: Fri, 13 Jun 1997 15:35:07 -0500 From: Dick Hendrickson The subject line pretty much says it all. Is a blank needed between the keyword PRINT and the format string "(i5)" in free form source? I've tried it on several compilers and only one of them objects. I think it's right, a blank is required. Section 3.3.1 says "A blank must be used to separate names, constants, or labels from adjacent keywords, names, constants, or labels. For example, in ... READ 10 ... the blank [is] required" I think R420 is clear that the " or ' are part of the char-literal-constant. The sentence preceding R420 is confusing because it talks about "a sequence of characters, DELIMITED by either apostrophes or quotation marks". But that's probably just loose wording. Sectionb 3.2 makes it clear that a character literal constant is a token and 3.2.6 does not include either " or ' as a delimiter. I suppose we could ask the same question about print* and I think the answer is the same. A blank is required. Dick ------------------------------------------------------------------------------ Date: Mon, 16 Jun 1997 21:10:33 -0700 From: Richard Maine I agree with your analysis - no other citations to add, just expressing agreement. ------------------------------------------------------------------------------ From: malcolm@nag.co.uk (Malcolm Cohen) Date: Wed, 18 Jun 1997 15:26:00 +0000 (BST) > I suppose we could ask the same question about print* and I think the answer > is the same. A blank is required. No, an asterisk is not a keyword, name, constant or label. Lexically, it is an operator (3.2,3.2.3). Similarly, although "print3,x" and "printstring,x" are lexically bad, "print.myop.3,x" and "print+string,x" are lexically ok - in particular they are not affected by 3.3.1. ------------------------------------------------------------------------------ Date: Tue, 16 Sep 1997 15:11:48 -0500 [ From a coworker here at SGI/CRI ] I believe Malcolm Cohen's argument that * is exempt because it is an "operator" is quite weak. The * symbol is used, depending on context, as an operator, statement label, character length specifier, array bounds specifier, default I/O unit number, etc. Claiming that the * symbol is an operator in the context of "print *,..." seems incorrect. Given that the standard already notes that a blank is required in "read 10", it seems hard to argue that one is not required after the PRINT keyword. However, given traditonal usage, I would think it very unlikely that any vendor would actually enforce this rule. It seems only relevant for the flagging requirement. ---------------------------------------------------------------------------- Larry Rolison lrr@cray.com Cray Research, A Silicon Graphics Company 655F Lone Oak Drive Eagan, MN 55121 ----------------------------------------------------------------------------