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

greg greg at cosc.canterbury.ac.nz
Fri Nov 21 20:06:53 EST 2008


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.

Whether they're "the same" depends on what you mean by "same".
If you define "same" in such a way that they're not, then that
definition of "same" is irrelevant to the matter at hand.

-- 
Greg



More information about the Python-list mailing list