Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!fernwood!uupsi!cmcl2!lanl!cochiti.lanl.gov!jlg From: jlg@cochiti.lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Fortran 90 status Message-ID: <22900@lanl.gov> Date: 30 Apr 91 15:32:33 GMT References: <1991Apr24.202115.16119@dragon.wpd.sgi.com> <1991Apr25.235111.26282@alchemy.chem.utoronto.ca> <1991Apr26.142249.21064@convex.com> <1991Apr29.140241.1@dev8n.mdcbbs.com> Sender: news@lanl.gov Organization: Los Alamos National Laboratory Lines: 96 In article <1991Apr29.140241.1@dev8n.mdcbbs.com>, campbell@dev8n.mdcbbs.com (Tim Campbell) writes: |> Richard; |> [...] |> I was especially happy to read the features in "What's good about Fortran |> Extended ?". I was especially happy to see structures and pointers made it |> into the standard . I was one of the people who suggested pointers in the first public review (like most others I hear). However, if I had known what they were going to do with them I would never have suggested them. The Fortran 90 proposal contains the _worst_ pointer definition that I have ever seen in a programming language. The use of pointers to array slices is a practice which in years to come will rank with implicit equivalencing through COMMON as a practice to be avoided at all cost. |> [...] |> I do have one little thing I absolutely drives me nuts about Fortran 77 and I |> hope it's been addressed: Prototyping! [...] Yes! The proposal does include a feature called "interface specifications" which perform this function. Not only that, but since the arguments are type checked at compile time, the interface specifications provide a means of overloading a single procedure name for generic operation. Here are some examples from the proposed standard document (June 1990): INTERFACE SUBROUTINE EXT1 (X, Y, Z) REAL, DIMENSION (100, 100) :: X, Y, Z END SUBROUTINE EXT1 SUBROUTINE EXT2 (X, Z) COMPLEX (KIND=4) Z(2000) END SUBROUTINE EXT2 FUNCTION EXT3 (P, Q) LOGICAL EXT3 INTEGER P(1000) LOGICAL Q(1000) END FUNCTION EXT3 END INTERFACE The arguments to each of these procedures must match the definitions given in the interface as far as type _and_ size (the array arguments must be conformable to the sizes given - an unspecified size would be denoted by a colon (:) as the size in the interface). When a procedure has been 'interfaced', you can call it with keywords for the arguments: EXT3 (Q = P_MASK (N+1 : N+1000), P = ACTUAL_P) Generic procedures are implemented by giving several different interfaces in a named interface specification block: INTERFACE SWITCH SUBROUTINE INT_SWITCH (X, Y) INTEGER INTENT (INOUT) :: X, Y END SUBROUTINE INT_SWITCH SUBROUTINE REAL_SWITCH (X, Y) REAL INTENT (INOUT) :: X, Y END SUBROUTINE REAL_SWITCH SUBROUTINE COMPLEX_SWITCH (X, Y) COMPLEX INTENT (INOUT) :: X, Y END SUBROUTINE COMPLEX_SWITCH END INTERFACE Now you can call SWITCH with any of the three argument configurations and the compiler will automatically select the correct version to use: CALL SWITCH (MAX_VAL, LOC_VAL) ! MAX_VAL and LOC_VAL are of type INTEGER |> [...] Will Fortran 90 tell me if I try to pass |> arguments to a subroutine which doesn't match the type of arguments expected? A Fortran 77 implementation _could_ have been doing this all along. The problem is that checking that the arg types match was a job that the _compiler_ couldn't do because it couldn't make use of interprocedural knowledge (and remain compatible with the possibility of separate compilation). That being the case, the job could only have been done at load-time or run-time. Nobody wanted to pay for the run-time check, and loaders never bothered to do it (probably because _some_ people actually want to cheat the type checking in this way - that's the problem with not giving the user an _explicit_ way to defeat type checking). Obviously, procedures with interface specifications can (and actually _must_) check the argument types. This can be done at compile time. J. Giles