Difference between Pass-by-Reference and Pass-by-Value-Result:
- 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
- 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.
- Consider also the following example, where Pass-by-Value-Result differs
VAR i,j: INTEGER;
i:= 2; j:= 3;
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.