On Jul 13, 11:58 pm, sturlamolden <[EMAIL PROTECTED]> wrote:

<snip>

> In Fortran you can only pass references.
>
> integer(4) :: a
> a = 1
> call bar(a)
>
> subroutine bar(a)
> integer(4) :: a
> a = 0             ! side-effect
> end subroutine
>
> That means, when a variable is used to call a function, the function
> receives a pointer to the actual argument, not a local copy. That is
> very different from C's copy-passing behaviour.

In Fortran, if a procedure argument is modified within the procedure,
that change is propagated to the value of the argument in the caller.
The standard does NOT mandate how this is accomplished, and one could
in theory write a compiler that makes a local copy of all procedure
arguments, as long as the variables passed as arguments were updated
in the caller. Early implementations of Fortran 90 often made copies
of array arguments, hurting performance. Current compilers do this
less often.

It is common to pass constants and expressions to Fortran procedures,
which does not fit the pass-by-reference paradigm.

Fortran 2003 has the VALUE attribute to give the C pass-by-value
behavior when desired.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to