anything like C++ references?

Stephen Horne intentionally at blank.co.uk
Tue Jul 15 00:20:48 EDT 2003


On Mon, 14 Jul 2003 20:57:44 -0700, Tom Plunket <tomas at fancy.org>
wrote:

>Stephen Horne wrote:
>
>> >Are they really technicalities, though?  I mean, a mutable object
>> >can be changed.  It's the same object, just changed.  Immutable
>> >objects, however, can't be changed.  You can get something that
>> >appears like changing it, but it's actually building a new thing
>> >and binding the label to that new thing.
>> 
>> Yes. But the thing being changed *is* an object, *not* a value. Values
>> are always immutable - basic fact of mathematics.
>
>Sure, but we're not modelling pure mathematics, we're modelling a
>level of abstraction that's appropriate for the problem that
>we're solving.

If that were true, the abstraction would not regularly be causing
confusion and errors, and it would not be a recurring issue on this
newsgroup.


>class Chameleon: pass
>
>a = Chameleon()
>b = a
>
>now, a and b represent the same thing.  Say it's a chameleon out
>in the woods.
>
>If I say:
>
>a.ClimbTree()
>
>then I expect
>
>b.GetColor()
>
>to return some brown color, since a and b are referring to the
>same critter.

All this tells me is that you have got used to the current Python way.
Personally, I think that if you want indirect references to objects
you should ask for them explicitly. That way there's no confusion.

>I don't agree, because Python is a language that allows us to
>model objects in a way that is comfortable to us.  If I wanted to
>use a more mathematically pure language, I would, but that
>language would likely not be suited to the problems I'm trying to
>solve.

Comfortable to those who are used to it, perhaps. But again, the fact
of regular confusion and errors, and of the issue regularly
reappearing in the group, shows that this 'comfort' is a very long way
from being universal.





More information about the Python-list mailing list