0

Explain Python's pass by references Vs pass by value . Explain about Python's parameter passing mechanism?

2nd Apr 2018, 7:40 AM
Ashwani Kumar Kamal
Ashwani Kumar Kamal - avatar
2 Respostas
+ 3
First of all, so-called "pass-by-object-reference" is just pass-by-value. People use it to describe languages where the values in the languages are references (i.e. pointers to objects), not objects themselves, and thus passing by value would pass the pointer to object. I will first define what I mean by pass-by-value and pass-by-reference, since there are many arguments on this topic due to people not having the same definition or not having a clear definition. Pass-by-reference: Simple assignment (i.e. "=") to a parameter variable inside a function has the same effect as simple assignment to the variable passed to that function in the calling scope. Pass-by-value: Simple assignment (i.e. "=") to a parameter variable inside a function has no effect on the calling scope. Under this definition, languages like C, Java, Python, JavaScript, Ruby, Go, Smalltalk, Scheme, and others, are all pass-by-value only. C++, C#, and PHP have both pass-by-value and pass-by-reference, where it is pass-by-reference if the parameter is marked "&" (in C++ and PHP) or "ref" or "out" (in C#), and pass-by-value otherwise. https://www.quora.com/What-is-the-difference-among-pass-by-reference-pass-by-value-and-pass-by-object-reference
2nd Apr 2018, 8:00 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
2nd Apr 2018, 11:34 AM
visph
visph - avatar