Parameter Passing: Difference between revisions

 
Line 150:
 
===Example [[Fortran]]===
Early versions of the language used only by reference parameter passing for the arguments, but the formal parameters were copied locally and then copied back to the actual parameters at the end of the call. This is also known as "call by value result" or "call by copy-restore".
 
Starting from Fortran 90 (and later), functions and subroutines can specify an ''intent'' for the argument; intent can be: '''in''' (unmodificableunmodifiable argument), '''out''' (argument used to return a value; the starting value must be intended not significativesignificant, undefined), '''inout''' (argument both is intended for input and can be modified, i.e. return the value modified by the function/subroutine).
 
Trying to modify an argument with ''intent in'' triggers an error at compile time.
44

edits