Chapter 6: Runtime System

Parameter Passing

. Call by value

- actual parameters are evaluated and their rvalues are passed to the called procedure

- used in Pascal and C

- formal is treated just like a local name

- caller evaluates the actual parameters and places rvalue in the storage for formals

- call has no effect on the activation record of caller

This is, in a sense, the simplest possible method of passing parameters. The actual parameters are evaluated and their r-values are passed to the called procedure. Call-by-value is used in C, and Pascal parameters are usually passed this way. Call-by-Value can be implemented as follows:

1. A formal parameter is treated just like a local name, so the storage for the formals is in the activation record of the called procedure.

2. The caller evaluates the actual parameters and places their r-values in the storage for the formals. A distinguishing feature of call-by-value is that operations on the formal parameters do not affect values in the activation record of the caller.