Home Segments Top Top Previous Next

132: Sidetrip

One alternative to call-by-value parameters, characteristic of some languages, is provided by call-by-reference parameters. If a parameter is a call-by-reference parameter and the corresponding argument is a variable, then the parameter shares the same chunk of memory with the argument variable:

Memory reserved                 Memory supplying a value for 
for a variable in               a corresponding parameter in  
calling program                 called program 
  |                               | 
  |  *----------------------------* 
  v  v    
*------* 
|      | 
*------* 

If a parameter is a call-by-reference parameter and the corresponding argument is a variable, a parameter reassignment inside the called program propagates outside to the calling program.