Home Segments Index Top Previous Next

122: Mainline

It is important to know that the parameter values established when a function is entered are available only inside the function. It is as though C builds a isolating fence to protect any other uses of the same parameter name outside of the function. Consider doubling_time, for example:

double doubling_time (double r) { 
  return log (2.0) / log (1.0 + r / 100.0); 
} 

When doubling_time is used, any existing values for other variables that happen to be named r are protected:

doubling_time fence ---------------* 
| The value of r inside this fence |   The values of r 
| is isolated from values outside  |   outside the fence, 
|                                  |   if any, are not 
| Function computes the doubling   |   affected by the value 
| time using the value of r        |   inside 
| inside this fence                | 
*----------------------------------*