J3/12-197 To: J3 From: Malcolm Cohen Subject: Interp F08/0075 Date: 2012/10/18 1. Introduction It is proposed to remove the operator syntax for denoting a variable. This currently can appear in various places, including (a) left-hand of assignment statement, (b) input-list in READ statement, (c) actual argument, (d) ASSOCIATE/SELECTTYPE selector. There are several levels of possibility here: (1) remove fully; (2) remove in some subset that is bigger than the known-problematic cases (a) and (b), but less than the whole set; (3) remove only in the known-problematic cases (a) and (b). Section 2 contains the answer and edits for the interp for option (1), remove fully. 2. The interp ---------------------------------------------------------------------- NUMBER: F08/0075 TITLE: Pointer function reference as variable in assignment KEYWORDS: Pointer function, assignment, defined operator DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: (1) Consider the following module Funcs interface operator ( .op. ) module procedure Unary, Binary end interface contains function Unary ( Arg ) integer, intent(in) :: Arg integer, pointer :: Unary ... end function Unary function Binary ( Arg1, Arg2 ) integer, intent(in) :: Arg1, Arg2 integer, pointer :: Binary ... end function Binary end module Funcs program What use Funcs integer :: X, Y = 42 10 .op. x = y end program What Is the "10" in "10 .op. x = y" an operand, and therefore an argument of a reference to Binary, or is .op. a reference to Unary and "10" a statement label? (2) Consider the following module Funcs interface operator ( .op. ) module procedure Unary, Binary end interface contains function Unary ( Arg ) integer, intent(in) :: Arg character(len=...), pointer :: Unary ... end function Unary function Binary ( Arg1, Arg2 ) integer, intent(in) :: Arg1, Arg2 character(len=...), pointer :: Binary ... end function Binary end module Funcs program What use Funcs integer :: X = 42, Y read (10) .op. x, y end program What Is "10" an , or is "(10) .op. x" a ? Note that this program is valid Fortran 90, and "(10) .op. x" is a according to the Fortran 90 standard. ANSWER: It was an oversight that the programs in (1) and (2) conform to the syntax and constraints in two different ways. The problem stems from the over-ambitious extension of allowing pointer function references to denote variables; this was unambiguous for syntax, but is not for operator syntax. Also, operator syntax has other restrictions on it that are intended to prevent modification of an operand, and these are subverted if the result is treated as a variable. Edits are supplied to remove the treatment of pointer-valued operators as variables. EDITS: [117:13] In 6.2, R602, change "" to "". [117:15] In 6.2, C602, change " ... has" to " shall have". [158:18+] In 7.2.2.2, R737, add new production "<> ". {Restore description of to F2003 version.} [158:20+] In 7.2.2.2, After C724, add new constraint "C724a (R737) An shall be a reference to a function that has a data pointer result." {Restore F2003 constraint (more or less).} SUBMITTED BY: Van Snyder HISTORY: 12-149 m198 F08/0075 submitted 12-149r1 m198 Revised edit. 12-149r2 m198 Clarified answer, passed J3 meeting 12-196 m199 Subsumed F08/0076 and Failed J3 letter ballot #26, 12-184. 12-197 m199 Revised answer and edits. ----------------------------------------------------------------------