Finding the instance reference of an object

Douglas Alan doug at alum.mit.edu
Thu Nov 20 06:27:06 CET 2008


Joe Strout <joe at strout.net> writes:

>>   Q. What type of calling semantics do Python and Java use?
>>
>>   A. Call-by-sharing.
>
> Fair enough, but if the questioner then says "WTF is call-by-sharing,"
> we should answer "call-by-sharing is the term we prefer for call-by-
> value in the case where the value is an object reference (as is always
> the case in Python)."

Personally, I think that it is much preferable to leave
"call-by-value" completely out of any such discussion, as it provably
leads to a great deal of confusion and endless, pointless debate.
It's better to just start from a clean slate and explain how
call-by-sharing works, and to assert that it is quite different from
the calling semantics of languages such as C or Pascal or Fortran, so
the student must set aside any preconceptions about how argument
passing works.

Call-by-sharing is technically a type of call-by-value only for those
who are devotees of academic programming language zoology.  For
everyone else, call-by-sharing is its own beast.  One might point all
of this out in the discussion, however, if it will help the other
person understand.  You never know -- they might be a fan of academic
programming zoology.

|>oug



More information about the Python-list mailing list