Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site spuxll.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxj!houxm!whuxlm!spuxll!ech From: ech@spuxll.UUCP (Ned Horvath) Newsgroups: net.lang Subject: Re: Constants in subroutine calls Message-ID: <606@spuxll.UUCP> Date: Wed, 9-Jan-85 13:05:48 EST Article-I.D.: spuxll.606 Posted: Wed Jan 9 13:05:48 1985 Date-Received: Fri, 11-Jan-85 22:47:34 EST References: <468@ecsvax.UUCP> Organization: AT&T Information Systems, South Plainfield NJ Lines: 21 This awful FORTRAN behavior is wired into the STANDARDS, to wit: FORTRAN uses call by 'value-result': each argument is copied, the copies are passed, and at return the copies are copied back to the original arguments. This is not quite the same as call by reference, since (for example) you can pass a variable which is in COMMON and the subroutine can modify either copy without the effects being replicated in the other -- until it returns! Unfortunately, many compiler writers simply implemented call by reference. You can test your compiler with the above example: pass a COMMON variable, modify the parameter, and see if the COMMON variable reflects the change WHILE STILL IN THE SUBROUTINE. If so, you have call by reference. Note that either call by reference or call by value-result will clobber your constants. The trick recently suggested -- pass (1.0) rather than 1.0 -- is a nice way to defeat this in FORTRAN, works fine in PL/I (call by reference) also. Beware, however: your 'optimizer' might just be braindamaged enough to strip off the parens! =Ned=