On Oct 14, 2011, at 12:24, glen herrmannsfeldt wrote: > (someone wrote) >> My understanding is that the C standard calls for all parameters >> to be passed by value. My experience is that IBM's C usually >> passes parameters by reference except that if a parameter is a >> pointer it gets passed by value. Go figger. > > That is most consistent with the way it was traditionally done. > > The requirement is for "as if" to work. It should be possible to > pass the addresses and the callee makes a local copy, or pass > addresses of copies. > > The OS/360 Fortran compilers (G and H) make local copies of scalar > variables, and then copy them back before return. (Usually > described as call by value result.) That is legal Fortran. > FORTRAN tries pretty hard to accommodate the idiosyncrasies of various implementations. I suppose that to make this all work the Standard must contain a statement that if a variable is passed as a parameter but the called routine modifies it via a COMMON block, the effect is implementation-dependent.
> For a Fortran call, local variables will have compile time > (relocatable) address constants, but dummy arguments arrays > will use the address passed in with the call. > > PL/I passes the address of a temporary variable for expression > arguments, or arguments known to have different attributes. > > To be most consistent with the OS/360 calling conventions, > as a series of A-type address constants, the last with the high > bit set, one would either pass addresses of copies, or expect > the called routine to make copies. That would allow for calls > between C and other languages. > But it doesn't. If the actual parameter is a pointer, IBM's C places not the address of that parameter but its value on the stack (or in the parameter block). -- gil
