passing by refference

Terry Reedy tjreedy at udel.edu
Tue May 20 22:56:16 EDT 2003


"Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> wrote
in message news:baejai$sjcop$1 at ID-169208.news.dfncis.de...
> Tim Peters wrote:
> > The notion of object identity is also important.  The
call-by-object
> > business explicitly addresses all of them (read Liskov or Baker,
previously
> > referenced).  By itself, "call by value" doesn't;
>
> What would y'all think of the following way of phrasing
> it:
>
>     Python passes references to objects by value.

Since you asked ... ugh.

> It seems to me that the concept of passing something by
> value, as opposed to passing it by reference, applies
> perfectly well to Python.

To me, *neither* apply.

> We just need a way of referring
> to the concept while making it clear *what* it is that's
> being passed.

Nothing.

As I tried to explain in an earlier post in this thread, I view Python
as a language for describing and manipulating typed information
objects.  From this viewpoint, nothing is being 'passed'.  The
interpreter simply binds a name to an object resulting from an
expression evaluation in that namespace instead of this one.

When you read and interpret Python code and come accross a function
call, do you
'pass references to objects by value", either actually or
imaginatively?  I don't, I don't believe, but then I have not
programmed a line of C for several years.  Mentally associating
argument objects with parameter names does just fine for me.

Not only is Python not C, it is not 'the' CPython implementation, even
if such standard-release implementation gives defacto definition of a
particular version -- by its externally observable behavior, not by
internal implementation.

> I think the above phrasing achieves that.
> Does anyone agree?
>
> P.S. I make no apology for using the word "reference"
> either, since I'm also stating what the reference is
> referring to. I don't understand why there is so much
> opposition to using this word when talking about Python.

Coming from C (after reading about C++), I naturally used it myself -- 
certainly privately and probably publically.  But it has always
bothered me and increasingly seems to me unnecessary and even
diversionary.

> I maintain that, to correctly understand Python's data
> model, you need some concept in your brain that's
> functionally equivalent to a reference

As far as I see, the concept in mainly needed if one insists on
imagining a comprehensible 'mechanism' for name binding, even though
we do not understand yet how we ourselves do so (or why we sometimes
fail to make or keep bindings that we think we ought to).

>  -- so why not call it that?

'reference' is more a less a synonym for 'identify', which latter is a
necessary concept/word.  I am no longer sure that another words helps.

Terry J. Reedy










More information about the Python-list mailing list