Official definition of call-by-value (Re: Finding the instance reference...)

Aaron Brady castironpi at gmail.com
Fri Nov 21 20:30:26 EST 2008


On Nov 21, 7:06 pm, greg <g... at cosc.canterbury.ac.nz> wrote:
> Aaron Brady wrote:
> > Tell me, what happens during a call to the following C++ function?
>
> > void f( std::vector< int > x );
>
> The same thing as would happen if you wrote
>
>    std::vector<int> x = actual_parameter_expression;
>
> > what happens during a call to the following Python
> > function?
>
> > def f( x ): ...
>
> The same thing as would happen if you wrote
>
>    x = actual_parameter_expression
>
> > If not, which one is call-by-value?
>
> They're both call-by-value, because they're both equivalent to
> assignment according to the rules of the language concerned.

No, you have described call-by-equals-sign, or call-by-assignment.
While call-by-assignment and call-by-value are equivalent in C++, that
does not make your rule hold for all languages.  Python is call-by-
assignment too, as well as call-by-sharing.  Just because a language
is call-by-assignment, is not sufficient (or necessary) to be call-by-
value.  Call-by-value has other characteristics that Python does not
meet.




More information about the Python-list mailing list