Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!cbosgd!clyde!watmath!orchid!atbowler From: atbowler@orchid.waterloo.edu (Alan T. Bowler [SDG]) Newsgroups: comp.lang.c Subject: Re: compilers and linkers Message-ID: <11772@orchid.waterloo.edu> Date: Fri, 20-Nov-87 13:31:02 EST Article-I.D.: orchid.11772 Posted: Fri Nov 20 13:31:02 1987 Date-Received: Mon, 23-Nov-87 04:38:52 EST References: <33890@sun.uucp> <387@sdcc15.UUCP> <180@sdti.UUCP> Reply-To: atbowler@orchid.waterloo.edu (Alan T. Bowler [SDG]) Organization: U. of Waterloo, Ontario Lines: 26 In article <180@sdti.UUCP> turner%sdti@harvard.harvard.edu (Prescott K. Turner, Jr.) writes: >In article <387@sdcc15.UUCP>, gp3147@sdcc15.UUCP (Tom Stockfisch) writes: >> In article <33890@sun.uucp>, limes%ouroborous@Sun.COM (Greg Limes) writes: >> > ...In at least one FORTRAN compiler that I know of, parameters are >> > passed by address to subroutines. >> This is true of ALL Fortran compilers. > >Fortran would be better off if this were so. However, both the Fortran 77 >standard and the new proposed Fortran restrict the kinds of aliasing which >a program can use, so that compilers can handle parameters by >copy-in/copy-out. > The fact the the subroutine handles the passed value with a copy-in/copy-out rule does not change the fact that the parameter was passed to the subroutine by address. The act of making a local copy of the parameter is done by the subroutine (and on the IBM compilers can be overridden), for efficiency. The subroutine linkage used by the caller just passes addresses for everything. One could imagine an implementation where the choice was made by the caller between copy-in/copy-out, and reference, but it would have be a strange architecture for it not to be less efficient in both memory and time. Furthermore, it would not allow some relatively common (though questionable) practices such as passing a scalar as a 1 element vector. As far as I know, the statement that ALL Fortran compilers pass parameters by address is true.