Is 'everything' a refrence or isn't it?

Bryan Olson fakeaddress at nowhere.org
Sat Jan 7 11:17:58 EST 2006


Steven D'Aprano wrote:
> Bryan Olson wrote:
>>Wrong. C does not have references, and the Python use is consistent
>>with the rest of computer science. You seem to have read in things
>>that it does not mean. Fix *your* thinking.
> 
> 
> Bryan, I'll admit that I'm no C/C++ programmer, and I frequently assume
> that if X is true for C++ it is also true for C, and vice versa. I
> appreciate being corrected when I make a mistake.
> 
> However, in this case, I think you are confused by the term references.

No, though I should have had "references" in quotes; C doesn't
call anything a reference, so saying it confuses people about
what references are doesn't make sense.

[...]
> I'll admit that my position on this question has changed. I no longer say
> that "everything in Python is a reference" is *false*, not in the weak,
> generic sense. 

Of course it's false. Is indentation a reference? Is a comment
a reference? The bad term there is "everything", not "reference".

 > How can it be? In the generic sense, Python names are
> references. (Under the hood, names may even be implemented as C++
> references for all I know.) I will still argue that the term reference is
> harmful, not because it is technically incorrect, but because it activates
> incorrect mental models of Python's high-level behaviour in too many
> people.

Mike wrote that lists contain references. You said that was
nonsense as they contain objects. His description was right and
consistent with Python behavior. Yours was wrong and inconsistent
with Python behavior. List storing references is the *right*
mental model.


>>>That's why people come to Python with a
>>>frame that tells that what call by reference implies ("I can do this...")
>>>and then they discover that they often *can't* do that.
>>
>>I'm sorry if you got confused, but please don't project it on
>>the rest of the discipline. 
> 
> Perhaps you should check out the beginning of the thread before making
> any additional comments. It wasn't me who was confused and asked "Hey
> what's going on? I was told everything in Python is a reference, but when
> I do this it doesn't work." I'm not projecting anything on anyone.

Read more carefully. His problem was in understanding variable 
assignment in C versus Python: storage in a location versus name
binding. He got some good explanations. Unfortunately there was
also quite a bit of wrong reporting, which some of us are trying
to correct.


-- 
--Bryan



More information about the Python-list mailing list