Finding the instance reference of an object

Steve Holden steve at holdenweb.com
Fri Nov 7 06:52:06 CET 2008


Joe Strout wrote:
> First, I want to thank everyone for your patience -- I think we're
> making progress towards a consensus.
> 
Phew.
> 
>> But putting that aside, consider the Python
>> code "x = 1". Which statement would you agree with?
>>
>> (A) The value of x is 1.
> 
> Only speaking loosely (which we can get away with because numbers are
> immutable types, as pointed out in the last section of [1]).
> 
I'd agree this is a valid way to describe the post-condition of the
assignment.

>> (B) The value of x is an implementation-specific thing which is
>> determined at runtime. At the level of the Python virtual machine, the
>> value of x is arbitrary and can't be determined.
> 
> Hmm, this might be true to somebody working at the implementation level,
> but I think we're all agreed that that's not the level of this
> discussion.  What's relevant here is how the language actually behaves,
> as observable by tests written in that language.
> 
I'd actually say "x contains a reference to 1", claim that was
equivalent to (A) above and cite Humpty Dumpty as my justification [1].

>> If you answer (A), then your claim that Python is call-by-value is false.
> 
> Correct.
> 
>> If you answer (B), then your claim that Python is call-by-value is true
>> but pointless, obtuse and obfuscatory.
> 
> Correct again.  My answer is:
> 
> (C) The value of x is a reference to an immutable object with the value
> of 1.  (That's too wordy for casual conversation so we might casually
> reduce this to (A), as long as we all understand that (A) is not
> actually true.  It's a harmless fiction as long as the object is
> immutable; it becomes important when we're dealing with mutable objects.)
> 
I am unsure here as to why you find it necessary to refer to 1's
immutability. How does this alter the essence of the situation?

[...]
> 
> Not that I'm trying to argue from authority; I'm trying to argue from
> logic.  I suspect, though, that your last comment gets to the crux of
> the matter, and reinforces my guess above: you don't think c-b-v means
> what most people think it means.  Indeed, you don't think any of the
> languages shown at [1] are, in fact, c-b-v languages.  If so, then we
> should focus on that and see if we can find a definitive answer.
> 
You're right. Observable progress, I think.

regards
 Steve

[1] http://www.sundials.org/about/humpty.htm
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list