Modifying Class Object

Alf P. Steinbach alfps at start.no
Wed Feb 10 17:56:36 EST 2010


* Steven D'Aprano:
> On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote:
> 
>> "pointer" refers to a copyable reference value as seen from the Python
>> level, in the same way as "pointer" is used by e.g. the Java language
>> spec.
> 
> Python doesn't have "copyable reference values" in the Python level. It 
> has objects.

Given

   s = [1]
   t = s         # Copies reference.
   t[0] = 2      # Changes referenced object via copied reference.
   print( s )    # Checks the object via the original reference.

your argument that the copied reference does not exist, is just silly.

And you know it.



> It seems to me that your argument is based on the premises:
> 
> (1) that the "value" of a variable is not what 99.99% of people would 
> describe as the value, but is some hidden, implementation dependent 
> "pointer" instead;

No. The Python language spec defines what value of an object means. And people 
use "value" with many different meanings, using Common Sense to arbitrate.

It would be senseless to try to pin down a single meaning of the word "value".

You're arguing against a position unrelated to mine.


> (2) that "pointer" doesn't necessarily mean what 99% of people who 
> learned C or Pascal understand by pointer;

No.

But although this is "just" a terminological issue, it's worth discussing.

I refuse to believe that 99% of C and Pascal programmers believe that "pointer" 
only refers to the pointer implementation in their language of choice.

In my first article in this thread I specifically referred to the Java language 
specification, which says, first sentence in §4.3.1 in the 3.0 spec, that


   "The reference values (often just references) are pointers to these objects,
    and a special null reference, which refers to no object."


which is relevant to Python because Java has the same semantics, although Java 
"NullPointerException" is called "unbound" in Python (but this is again just 
terminology, not semantics). I.e., the general pointer term /can/ be used, and 
is used, for reference values. Only a willingness to misinterpret can cause 
confusion, at least when the terminology is defined, as I've done all the time.

Secondly I referred (actually that was in response to you) to a Stanford 
University introduction to pointers, comparing four languages including Java.

I didn't refer you to Wikipedia because that article seems to lack mention of 
reference based languages and does include a reference to an article that I 
wrote about pointers in C++ (now off-net), and given the noise level here it 
would therefore probably not help.


> (3) that mangling both common English and programmers' expectations in 
> that fashion is somehow more accurate and more useful than using the 35 
> year old term "call by object" (or "call by object reference");

No, I haven't stated any opposition to using that term; the archives show the 
opposite.

So for the second time here you're arguing against a silly position that I do 
not hold.


> (4) and, presumably because of some deeply-held belief that the only 
> parameter passing strategies that we're allowed to talk about are "call 
> by value" and "call by reference", no matter how much violence we do to 
> the concept of both value and pointer, Python and Java must be call-by-
> value since they clearly aren't call-by-reference.

Well that's the third time here that you're arguing against a silly position 
that I do not hold.


> Of these, the only one that I consider value is that Python and Java are 
> not call-y-reference. Otherwise, I reject all these premises,

Good rejection as far as 1, 3 and 4 are concerned.

Regarding the term "pointer", your point 2, I strongly encourage you to seek out 
the sources I've referenced and quoted.

For without a common language it's difficult to communicate, and if Python 
programmers should continue to not understand common terms then that would just 
further flame wars such as this thread has escalated to. Please seek out 
sources. Don't just take my word, instead, read e.g. what I've quoted, try out 
the example I've given, and so on: be critical (to your own assumptions also!).


> and 
> consequently none of your arguments make the slightest sense to me.

Well, you'd first have to examine at least one of my arguments. In this article 
you haven't, instead attacking a number of positions that I haven't advocated 
and do not hold, except for your silly denial of existence of references at the 
top. But that's just silly  --  consider the concrete example given.


> You 
> keep talking about Python operating on pointers. I've never used a single 
> pointer in 10+ years of Python coding, no matter how many times you tell 
> me I have. What the implementation of the Python virtual machine does is 
> not what I do high-level Python code, and the implementation is not the 
> language.

Here again you're conflating things and engage in a kind of denial coupled with 
a correct argument. It's hard to argue against such confusion. Instead I've 
tried above to address your only relevant point, by a concrete example.

Summing up, denying the existence of references, as you do at the top, is just 
silly; do consider the code example.

Your points 1, 3 and 4 attack positions that I do not hold and have not advocated.

Your point 2, about terminology, is important on its own. And I suggest you 
check out the references I've given. And read what I quoted from the language 
specification of a language with the same semantics as Python.


Cheers & hth.,

- Alf



More information about the Python-list mailing list