Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!samsung!dali.cs.montana.edu!milton!seymour From: seymour@milton.u.washington.edu (Richard Seymour) Newsgroups: comp.lang.fortran Subject: Re: Function calls in the middle of subroutine CALLs? -- Is it standard fortran 77 ???? Message-ID: <5283@milton.u.washington.edu> Date: 19 Jul 90 19:28:39 GMT References: <6381@helios.TAMU.EDU> <1990Jul19.014856.13421@maytag.waterloo.edu> Organization: University of Washington, Seattle Lines: 36 In article <1990Jul19.014856.13421@maytag.waterloo.edu> dmurdoch@watstat.uwaterloo.ca (Duncan Murdoch) writes: >In article burley@world.std.com (James C Burley) writes: >>In article <6381@helios.TAMU.EDU> forrest@eemips.tamu.edu (Bob Forrest) writes: >> "Is it part of the FORTRAN 77 standard to be allowed to make function >> calls in the middle of a subroutine CALL? -- assuming only FORTRAN >>But it seems clear you mean "in the middle" only >>in the sense of "as one of the arguments for a subroutine call". > >Does the standard specify in what order the arguments will be evaluated? >If they have side effects, it makes a big difference sometimes. I've been >bitten by a bug caused by the lack of such specification in Pascal. the old fortran 66 convention used to be left-to-right (unless overridden by operator precedence). but they were talking expression evaluation. DEC VMS F77 compiler very definitely warns you that optimization can really mess up the left-to-right stuff. Even providing guiding parentheses gets overridden by the optimizer. Even turning off optimization (in various releases of the compiler) did not protect you (or me (can you say "bitten"? shure you can...)) from occasional non left-to-right reordering of an expression. separating the critical steps to separate statement lines AND turning off optimization DID control non-obvious flow (i had variables in COMMON which were being asynchronously diddled, or actual device registers appearing as variables). SO -- the only way i've found to really be sure of execution order is to read the machine-language listing of the compiled program. The slightly less-ssure way is to expicitly pre-resolve function calls, etc. in previous lines, then call subroutines with only variable names in the argument list. Proper Structure Procedure (something i'm NEVER accused of) would dictate that any function/subroutine should ONLY affect items in the argument list (a function returns only the one value that it's called, right?), not background hidden things in COMMON, etc. Following that programming convention also guarantees not being bitten. good luck --dick