anything like C++ references?

Tom Plunket tomas at fancy.org
Mon Jul 14 23:57:44 EDT 2003


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.

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.

We could argue that "color" should be an immutable object within
the chameleon class, and I think argue quite successfully.
However, the chameleon itself doesn't become a different animal,
it still is the same size and has the same scars.

> Variables in mathematics are bound to values. I think Python 
> should be implemented in a way that respects that.

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.

> To me, 'Pythonic' expresses 'doing the right thing'. In this 
> case, in my view, Python does the wrong thing and expects 
> everyone to get used to it.

In my view, Python does largely what I want it to do regardless
of mathematical correctness.

-tom!

-- 
There's really no reason to send a copy of your
followup to my email address, so please don't.




More information about the Python-list mailing list