On 11/15/19 12:21 PM, Random832 wrote: > On Fri, Nov 15, 2019, at 11:47, Richard Damon wrote: >> The issue with calling it a Reference, is that part of the meaning of a >> Reference is that it refers to a Object, and in Python, Names are >> conceptually something very much different than an Object. Yes, in the >> implementation details, a name is basically a dictionary entry, so it >> could be done, the question is should it. > C# has basically the same issue and does fine calling its thing 'ref'. But > that's not really the point - my point was that the concept of being able to > have a function change the value of a variable specified by its caller > doesn't magically cease being applicable just because the value is a > "reference" and the variable is a "name binding". > > [Similarly, the fact that values are "references" to mutable objects doesn't > mean that python, or Java or C#, isn't call-by-value. The value is the > "reference" itself, the fact that it can be used to change data that exists > elsewhere is beside the point.]
My understanding is the C# is like the rest of the C* family that defining a variable x in the code, binds the name x to a specific object in memory at compile time. That name will ALWAYS refer to that object and that object can be thought to have that name, and no others in the same way. The object may be/have a reference to another variable. (C++ references are a bit different at the language level, a reference itself isn't an object, and taking the address of the reference 'object' give the address of the object that the reference refers to, C++ references are still compile time bound to a single object, but that object still has a concept of the name it was created through) (I will admit that I don't really know C#, but going from what I understand it as) This is NOT true in Python. A 'Variable Name' in Python is not statically bound to given object, but every assignment rebind the name to object mapping. Python does NOT use call by value, because a key feature of call by value is that the value being passed is copied, and the new copy is used in the subroutine. Name bindings are NOT values, objects have values, and the value of the object passed is NOT copied to somewhere else. It is only by misunderstanding the language, and trying to define a name as being some sort of pointer object that points to the 'real' value of object that you can create such an idea. This is NOT the model Python is defined with, and while it might help a bit when starting to understand how things work, you do need to move from that 'wrong' understanding to starting to think of it the way Python is defined, or many things in Python won't make sense. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list