| glen herrmannsfeldt 2007-10-31, 7:20 pm |
| George Neuner wrote:
> 28 Oct 2007 19:06:41 +0000, Anton Lokhmotov <al407@cam.ac.uk> wrote:
(snip)
:[color=darkred]
> <snip examples>
Fortran still allows call-by-value-result.
I first knew it used for scalar variables (only) on the
OS/360 Fortran G and H compilers. (Probably E also.)
For S/360 it is more efficient in time and space to copy a
scalar to local memory, addressed by the same base register
as the other data, and copy back later. In most cases it
takes two instructions to reference a variable through its
address. (One to load the address into a register, the
second to load or store as appropriate). For arrays,
OS/360 always does call by reference.
The usual case in current compilers is that in some cases Fortran
allows non-contiguous arrays to be passed. In other cases, arrays
are assumed contiguous. That can require a copy to be made before
the call, and copy back after, usually done by the caller not the
callee but the effect is the same.
[color=darkred]
> Fortran's semantics were designed to correspond with the behavior of
> real hardware - serial pipelined vector processors.
(snip)
> As a parameter passing method, CBVR was deprecated because most
> programmers found it confusing.
They still do, but it is still allowed.
-- glen
|