On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > Anton gave a picture explaining why/how references are needed and to be > understood
Antoon gave a picture demonstrating one model of Python's semantics. It's a nice model that has a lot going for it, in particular that it matches the most obvious implementation. But it doesn't describe *Python* semantics, it describes an overlap between Python the language and the implementation of the Python interpreter. In particular, consider the picture of a name binding to a value: +-----+ | | | 5 | | | +-----+ ^ | <x> This picture has three entities, but only two of them exist in Python: - the object 5; - the name "x" (names are not values in Python at runtime, but they are entities which exist in Python source code at compile time). The third entity is the reference linking the name to the object (the arrow). This isn't a runtime value in Python, nor is it a compile time entity that exists in source code. It is pure implementation, and as such, exists outside of the Python domain. I'm not saying that we should never use this model. Its a good model. But we should be clear that it is a model of the implementation, and it describes entities which are not part of the Python language. We cannot do this: +-----+ | | | 5 | | | +-----+ ^ | <x> ^ | <y> or any of the other things we can do in a language with references-as-values, like C or Pascal. [...] > Roger Christman compressed my foo and bar into one baz > > def baz(x,y): > x += y > > Which leaks or doesnt leak x-modifications depending on its type Yes, I see that -- but I don't see the point of it. What conclusion do you draw from that? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list