Skip to content

Commit

Permalink
Define call by value result and call by value.
Browse files Browse the repository at this point in the history
  • Loading branch information
amartini51 committed Sep 15, 2015
1 parent a8239e9 commit 171ef6f
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions ReferenceManual/Declarations.rst
Expand Up @@ -655,12 +655,34 @@ The corresponding argument must have no name in function or method calls.
In-Out Parameters
~~~~~~~~~~~~~~~~~

.. define call by value result
.. define call by reference
.. explain that #2 is used as an optimization
It-out parameters are passed as follows:

1. As part of the function call,
the value of the argument is copied.
2. During the body of the function,
the copy is modified.
3. As part of the function return,
the argument is assigned the copy's value.

.. TR: In (2) is it legal to access the original non-copied value?
This behavior is known as :newTerm:`call by value result`
or :newTerm:`copy-in copy-out`.
For example,
when a computed property or a property with observers
is passed as an in-out parameter,
its getter is called as part of the function call
and its setter is called as part of the function return.

As an optimization,
when the argument is a value stored at physical address in memory,
same memory location is used both inside and outside the function body.
The optimized behavior is known as :newTerm:`call by value`,
but still satisfies all of the requirements
of the call-by-value-result model
while removing the overhead of copying.
You should not depend on the behavior differences
between call by value result and call by value.

.. _Declarations_SpecialKindsOfParameters:

Expand Down

0 comments on commit 171ef6f

Please sign in to comment.