Difference between Pass-by-Reference and Pass-by-Value-Result:

  1. Pass-by-value-result is more efficient in partitioned memory where a Pass-by-Reference could refer to a distant segment or page, causing a page fault.  Similarly if memory is accessible through a network, it would necessitate a delay for network access.

  2. Concurrent execution could give unpredictable results.  Using Pass-by-Reference could end up giving values over some limit (see ticket sellers race-condition example).  Using Pass-by-Value-Result could end up with an invalid value, but it would always be less than the limit.

  3. Consider also the following example, where Pass-by-Value-Result differs from Pass-by-Reference:
       VAR i,j: INTEGER;
       PROCEDURE foo(x,y)
       i:= 2; j:= 3;
       foo( i,j)

    In Pass-by-Value-Result, x is a synonym for i on the call, but the value of x is never changed, so the changed value of i is restored to the original value when returning from the function.

    In Pass-by-Reference the change to i is kept back in the main program.


[CS Dept.] [UIC] [Prof. Reed]