On Mon, 4 Sep 2017 08:12 pm, Rustom Mody wrote: > Its because reference (or pointer or …) is central to python's semantics > that we need to use them to talk/explain/understand.
References are central to understanding the implementation of Python interpreters. (Perhaps not *all* interpreters, but using references of some sort is the most obvious and easy way to implement Python's semantics.) Dropping down into the implementation level and talking about references is often useful. But it is not essential -- one can explain a lot of code without any reference to "reference" ( pun intended *wink* ) at all. If we're willing to accept a conceptual model where Python objects are capable of being in two or more locations at once, we can explain ALL Python code without needing references. I accept that many people dislike, or do not understand, conceptual models where objects can be in more than one location at once. For many people, dropping into the implementation and talking about references is easier to understand. But that doesn't make it essential. The semantics of Python is that we assign objects to names, not references to objects to names. There's no "get reference" or "address of" operation in Python. We write: x = y not x = &y The interpreter may (or may not) use references or pointers in order to implement Python's object model, but strictly outside of the scope of Python the language. > Its because pointers have been de-first-classed (from C say, as a starting > point) that the disagreements arise: - One bunch feel that since they've been > de-first-classed they've been removed Pointers are not merely second-class values, like functions and procedures in Pascal, or strings in C. They're not values *at all*. Its not just that Python doesn't allow you to return a pointer from a function, or pass a pointer to a function as argument. You cannot dereference a pointer either, or get a pointer to an object at all. (Although you can emulate pointers in Python using objects.) For more about first-class values, see this Stackoverflow thread: https://stackoverflow.com/questions/2578872/about-first-second-and-third-class-value We can quibble whether Pascal functions are first-, second- or first-and-a-half class values, or whether "third-class" even makes sense, but pointers, and references, are not values of *any* class in Python. -- 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