Steven D'Aprano wrote:
On Fri, 07 Nov 2008 08:48:19 -0700, Joe Strout wrote:

Unfortunately, the term "name" is *slightly* ambiguous in Python. There are names, and then there are objects which have a name attribute, which holds a string. This attribute is usually called __name__ but sometimes it's called other things, like func_name.

3.0 corrects that divergence.
>>> def foo(): pass

>>> foo.__name__
'foo'

You're assuming that call-by-sharing isn't a standard term. That's not true. It's a standard term that is sadly not well known, I believe because of the ignorance of most coders to the history of their own discipline. (I include myself in that.)

-------------------------
http://en.wikipedia.org/wiki/Call_by_something#Call_by_sharing

Call by sharing

Also known as "call by object" or "call by object-sharing" is an evaluation strategy first named by Barbara Liskov et al for the language CLU in 1974[1]. It is used by languages such as Python[2] and Iota and (as argued by some[3]) Java, although the term is not in common use by the Java community. Call-by-sharing implies that values in the language are based on objects rather than primitive types.

The semantics of call-by-sharing differ from call-by-reference in that assignments to function arguments within the function aren't visible to the caller (unlike by-reference sematics). However since the function has access to the same object as the caller (no copy is made), mutations to those objects within the function are visible to the caller, which differs from call-by-value semantics.

Although this term has widespread usage in the Python community, identical semantics in other languages such as Java and Visual Basic are often described as call-by-value, where the value is implied to be a reference to the object.

---------------------------------
http://www.pmg.csail.mit.edu/papers/thetaref/node34.html

Call by Sharing
The caller and called routine communicate only through the argument and result objects; routines do not have access to any variables of the caller.

After the assignments of actual arguments to formal arguments, the caller and the called routine share objects. If the called routine modifies a shared object, the modification is visible to the caller on return. The names used to denote the shared objects are distinct in the caller and called routine; if a routine assigns an object to a formal argument variable, there is no effect on the caller. From the point of view of the invoked routine, the only difference between its formal argument variables and its other local variables is that the formals are initialized by its caller.

==========================
Python object *do* have access to surrounding scopes, but the second paragraph exact described Python, as does the corresponding Wikipedia entry.
==================================
myweb.lmu.edu/dondi/fall2004/cmsi585/subroutines-in-depth.pdf

• Call by sharing
– Used by languages where variables are already references to objects
– Parameters are references to objects, but assignments to those parameters
don’t change them at the level of the caller — e.g. Java uses call-by-value
for primitives (int, char) and uses call-by-sharing for Objects
-------------------------------------------

And Google had other links to course notes using 'call by sharing'

Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to