CallByValue

Last edit February 5, 2005
A ParameterPassing mode where the actual parameter is copied into the formal parameter at the point of function invocation (for example, implemented by copying into an agreed-upon register or location on the program stack).

Has the following attributes and consequences:

  • Does not introduce aliasing; caller and callee get separate copies.
  • Does not allow callee to influence state of caller (modifications to callee's formal parameter have no effect on caller; though there is a similar mode called CallByValueResult where the callee's formal parameter is passed back when the function returns).
  • Can be expensive to implement for large mutable objects, especially those which cannot fit in registers.
  • Forces expression evaluation at each passing point, i.e. all SideEffects are pre-call.

CallByValue refers to ParameterPassing modes with the above semantics, even if implemented differently under the hood.


See ParameterPassing, CallByReference, ExplicitLazyProgramming, CallByThunk
CategoryLanguageFeature