Finding the instance reference of an object

greg greg at cosc.canterbury.ac.nz
Thu Oct 30 20:38:23 EDT 2008


Douglas Alan wrote:
> greg <greg at cosc.canterbury.ac.nz> writes:
> 
>>Seems to me that (1) describes exactly how parameter passing
>>works in Python. So why insist that it's *not* call by value?
> 
> Because there's an important distinction to be made,

The distinction isn't about parameter passing, though, it's
about the semantics of *assignment*. Once you understand
how assigment works in Python, all you need to know then
is that parameters are passed by assigning the actual
parameter to the formal parameter. All else follows from
that.

This holds for *all* languages that I know about, both
static and dynamic. Once you know how assignment works in
the language concerned, then you know how parameter
passing works as well. There is no need for new terms.

> and the
> distinction has been written up in the Computer Science literature
> since Lisp first starting using the same argument passing semantics as
> Python back in 1958.  The semantics are called "call by sharing".

I still think it's an unnecessary term, resulting from
confusion on the part of the authors about the meanings of
the existing terms.

If there's any need for a new term, it would be "assignment
by sharing". Although there's already a term in use for that,
too -- it's known as reference assignment.

> Many mainstream programming languages other than Python now use call
> by sharing.  They include Java, JavaScript, Ruby, ActionScript, and C#.

I would say they use assignment by sharing, and call by
value.

-- 
Greg



More information about the Python-list mailing list