passing by refference

Tim Peters tim.one at comcast.net
Tue May 20 22:35:12 EDT 2003


[Greg Ewing]
> What would y'all think of the following way of phrasing
> it:
>
>     Python passes references to objects by value.

I think it's fine, provided you already know what it means *and implies*.
Newcomers would still be better off directed to Liskov's elaboration
(perhaps reworded a bit to fit Python exactly).

> It seems to me that the concept of passing something by
> value, as opposed to passing it by reference, applies
> perfectly well to Python. We just need a way of referring
> to the concept while making it clear *what* it is that's
> being passed. I think the above phrasing achieves that.
> Does anyone agree?

It's a lot better than the unqualified "call by value", yes.

> 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.
> I maintain that, to correctly understand Python's data
> model, you need some concept in your brain that's
> functionally equivalent to a reference -- so why not
> call it that?

I'm not in the anti-reference camp -- by the time you get around to
explaining recursive data structures in Python, you can draw pointers and
call them anything you like, but they're still references <wink>.






More information about the Python-list mailing list