------------------------------------------------------------------------------
MC logo
Call-by-Value-Result
[^] Functions
------------------------------------------------------------------------------
[Ch. 1: Overview and History] [Syntax] [Names and Scope] [Types and Type Systems] [Semantics] [Functions] [Memory Management] [Imperitive Programs and Functional Abstraction] [Modular and Class Abstraction] [Functional Programming] [Logic Programming]
[Call-by-Reference] [Call-by-Value-Result] [Call-by-Name] [Dyn Link Example] [Dyn Link Example] [C++ Translation of Java Dyn Link] [Variable Location] [Parameter Passing Method Exercise]
ref.for
      SUBROUTINE F(NA, NB)
      NA = NA + 3
      NB = NB + 5
      END

      NX = 10
      NY = 25
      CALL F(NX, NY)
      PRINT *, NX, NY
      NX = 10
      CALL F(NX, NX)
      PRINT *, NX
      END

If pass-by-reference is used, this gives the same result as the C++ expample:
13 30
18
If value-result is used, the results depend on which parameter is returned last. If done left-to-right, so NB is returned last, we get:
13 30
15
If we NA goes last, the last value is 13. This is because NA and NB are not alaises during the execution, each with an initial value of 10.