Parameter Passing
Several methods of passing parameters
between calling program and subroutine are used:
- Call by Reference:
The address of the parameter is passed.
The storage in the calling program is used (and possibly modified).
Used by Fortran, Pascal for var parameters, C for arrays.
- Call by Value: The value
of the parameter is copied into
the subroutine's memory. Modifications have no effect as seen by caller.
Expensive for large data. Used in Pascal, C for basic types.
- Call by Value - Result: The value of the parameter is copied into
the subroutine, and the result is copied back upon exit.
- Call by Name: The effect is that of a
textual substitution
or macro-expansion of the subroutine into the caller's environment.
Trouble-prone, hard to implement, slow. Used in Algol.
- Call by Pointer: A pointer to the parameter value is passed.
Used in Lisp.
Contents   
Page-10   
Prev   
Next   
Page+10   
Index