J3/04-300 Date: 4-May-2004 To: J3 From: JOR/interp/Stan Whitlock Subj: F95 interpretation #000008 NUMBER: 000008 TITLE: Optional arguments to MAX/MIN KEYWORDS: intrinsic function, MAX, MIN, optional, argument DEFECT TYPE: Interpretation STATUS: J3 consideration in progress BACKGROUND: Dick Hendrickson originally posed the question contained in this Interpretation Request. As will be seen in the Addendum, Richard Maine agrees with me that this question needs an official response. Hence, I am submitting on Dick's behalf (to steal a little more of his thunder). I have combined some of his and Richard's words. Any misstatements in transcription are most likely mine. This intro should be deleted later in the interp process. QUESTION: It appears that there is a missing "optional" in the description of the optional arguments [, A3, ...] in the MAX and MIN functions. In the Fortran 90 standard, the MAX/MIN descriptions said "optional arguments. A3, ...", but those words do not appear 13.14.64 of the Fortran 95 standard. Section 13.3 [217:27+] states ...optional arguments... are identified by the notation "optional" in the argument descriptions. and goes on to describe another notation for the arguments that are listed as optional. But it doesn't say anything about arguments given in [...] and NOT also listed as optional. Suggested change to the argument descriptions for MAX and MIN: Arguments. A1, A2 shall both have the same type which shall be integer or real and they shall both have the same kind type parameter. A3, ... (optional) shall have the same type and kind type parameter as A1. ANSWER: There is an anomoly in the presentation of MAX and MIN but the intent is clear, ie, dummy arguments A3 and beyond are optional. EDITS: NOne Notes: The attached addendum alludes to a possible interpretation that MAX (A1=1, A2=2, A4=4) is legal. We could find no such request. The same descriptive form reported here in Fortran 95 appears in Fortran 2003 for MAX and MIN. SUBMITTED BY: Larry Rolison / Dick Hendrickson HISTORY: 97-245 m143 submitted 04-300 m168 Submitted for J3 meeting vote - - - - - - - - Addendum: Dick's original question and the interchange that developed between he and Richard Maine: Date: Thu, 18 Sep 1997 13:02:28 -0500 To: x3j3@ncsa.uiuc.edu From: Dick Hendrickson Subject: (x3j3.1997-309) Is A3 optional for MAX or MIN functions My guess is that there is a missing "optional" in the description of [, A3, ...] in the MAX and MIN functions. In F90 the MAX/MIN descriptions said "optional arguments. A3,...", but I can't find those words in F95 13.14.64 Section 13.3 (217:27) says "...optional arguments... are identified by the notation "optional" in the arguments description." and goes on to describe another notation for the arguments that are listed as optional. But it say anything about arguments given in [...] and NOT also listed as optional. I don't know if we are doing bug fixes yet on F95, but shouldn't we change the argument description for MAX and MIN to Arguments. A1, A2 shall both have the same type which shall be integer or real and they shall all have the same type parameter. A3,... (optional) shall have the same type and type parameter as A1 It's clear what we meant to do, did I miss something simple somewhere? Dick - - - - - - - - Date: Thu, 18 Sep 1997 12:52:42 -0700 (PDT) From: Richard Maine To: Dick Hendrickson Cc: x3j3@ncsa.uiuc.edu Subject: (x3j3.1997-310) Is A3 optional for MAX or MIN functions Dick Hendrickson writes: > My guess is that there is a missing "optional" in the description > of [,A3,...] in the MAX and MIN functions. In F90 the MAX/MIN > descriptions said "optional arguments. A3,...", but I can't find > those words in F95 13.14.64 .... > It's clear what we meant to do, did I miss something simple > somewhere? Its not quite so clear to me. You may have missed something subtle. Some intrinsics have multiple interfaces and there are subtle but critical differences between an argument that is optional as opposed to an argument that is omitted from one or more of the interfaces. What isn't clear is which of these categories MIN and MAX fit into. Is it one interface with an infinite number of optional arguments or is it an infinite number of interfaces, each with a different number of required arguments? MIN and MAX are rather "special" in any case in that it is impossible to write an interface for them (in a finite number of lines of code). I'm not entirely sure that they fit in either category. I'm not sure of the correct answer here - all I'm saying is that it isn't as simple a case as it sounds at first glance. You can actually change what is or isn't legal depending on exactly how you describe MIN and MAX (consider the restrictions in 12.4.1.5). It may be an error in f95, but I'd treat it as a "real" question, not as a typo. -- Richard Maine maine@altair.dfrc.nasa.gov - - - - - - - - Date: Thu, 18 Sep 1997 17:05:29 -0500 To: Richard Maine From: Dick Hendrickson Subject: (x3j3.1997-312) Re: Is A3 optional for MAX or MIN functions At 07:52 PM 9/18/97 +0000, Richard Maine wrote: >Dick Hendrickson writes: > > > My guess is that there is a missing "optional" in the description > > of [,A3,...] in the MAX and MIN functions. In F90 the MAX/MIN > > descriptions said "optional arguments. A3,...", but I can't find > > those words in F95 13.14.64 > .... > > It's clear what we meant to do, did I miss something simple > > somewhere? > >Its not quite so clear to me. You may have missed something subtle. >Some intrinsics have multiple interfaces and there are subtle but >critical differences between an argument that is optional as opposed >to an argument that is omitted from one or more of the interfaces. > >What isn't clear is which of these categories MIN and MAX fit into. >Is it one interface with an infinite number of optional arguments or >is it an infinite number of interfaces, each with a different number >of required arguments? It's also not clear to me, but, as I read the MAX/MIN description in Fortran 90 I'd say that A3,... are each optional arguments; not that the description is a shorthand for an infinite number of lists. If this is correct then upwards compatibility demands (well suggests anyhow) that A3, A4, ... are each optional and this leads to the surprising result that MAX(A1=1,A2=2, A4=4 ) is legal. > It may be an > error in f95, but I'd treat it as a "real" question, not as a typo. I guess I agree with that, unless someone has an obvious answer. Dick - - - - - - - - Date: Thu, 18 Sep 1997 15:38:57 -0700 (PDT) From: Richard Maine To: Dick Hendrickson Cc: x3j3@ncsa.uiuc.edu Subject: (x3j3.1997-313) Re: Is A3 optional for MAX or MIN functions Dick Hendrickson writes: > If this is correct then upwards compatibility demands (well > suggests anyhow) that A3, A4, ... are each optional and this leads > to the surprising result that MAX(A1=1,A2=2, A4=4 ) is legal. I think there might have been an interp related to that, but too many hot non-J3 things right now for me to take the time to search the interps. -- Richard Maine maine@altair.dfrc.nasa.gov [ Added note from Larry: This time I could not find the interp that Richard maybe remembers. At least nothing showed up when I searched both the A and B categories using A4 and MAX. ]