Apology Re: Is 'everything' a refrence or isn't it?

Mike Meyer mwm at mired.org
Thu Jan 5 22:47:13 EST 2006


Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> On Thu, 05 Jan 2006 11:17:44 -0500, Mike Meyer wrote:
>> While telling them that "You can't do call by reference because Python
>> is call by object" may be correct, 
> Good to see you finally concede it.

I'm not conceeding anything, because I never said otherwise. In
particular, I still claim that Pythons behavior when passing objects
as parameters is identical to call-by-reference for all the objects
that you can generate in Python.

>> So they're liable to run into the same problem in a
>> different context - like the one the OP had.
> That doesn't follow. 

You're right. That observation is based on watching people repeatedly
beat their head against the difference between variable assignment in
other languages and name binding in object-based languages. Until you
get that difference into their heads, they're going to have
problems. What you use to describe the parameter passing mechanism is
immaterial to the real problem.

> The problem isn't that talk about references is *wrong*, but that it is
> misleading. Where "reference" is being used just as a generic term, it is
> barely acceptable, but any time it is used in a context where it could be
> misconstrued is dangerous precisely because people WILL misunderstand it,
> because they *think* they know what references (assignment, call by
> reference, whatever) means in this context.

This is where we disagree. I think their understanding of references
is dead on. What's broken is their understanding of what variables are
and what assignments mean. Once you fix that, the rest falls into
place.

> The fact that call by object is unfamiliar is precisely its advantage.
> Instead of people jumping to conclusions about what it means, like they do
> with "reference", they will stop and think and if need be look for further
> information about Python's object model. At the very least, they won't say
> "Everything in Python is a reference, so this should work, but it
> doesn't". 

What you're advocating is intentionally misleading people to deal with
a symptom. I'd rather give them enough truth to deal with the disease.

    <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list