What other languages use the same data model as Python?
Mel
mwilson at the-wire.com
Tue May 3 12:33:15 EDT 2011
Hans Georg Schaathun wrote:
> On 01 May 2011 08:45:51 GMT, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
> : Python uses a data model of "name binding" and "call by object" (also
> : known as "call by sharing"). I trust I don't need to define my terms,
> : but just in case:
>
> Without having the time to get my hand around exactly what this means:
> Simula has three ways of transmitting arguments, namely transmission
> by name, by value, and by reference. Is transmission by name the same
> as call by object? Anyway, I have never seen anyone counting more than
> three ways of doing this ...
To illustrate the neither-fish-nor-fowl nature of Python calls:
mwilson at tecumseth:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def identify_call (a_list):
... a_list[0] = "If you can see this, you don't have call-by-value"
... a_list = ["If you can see this, you have call-by-reference"]
...
>>> my_list = [None]
>>> identify_call (my_list)
>>> my_list
["If you can see this, you don't have call-by-value"]
so it's neither call-by-value nor call-by-reference as (e.g.) C or PL/I
programming would have it (don't know about Simula, so I am off topic,
actually.) It's not so wrong to think of Python's parameter handling as
ordinary assignments from outer namespaces to an inner namespace.
Mel.
More information about the Python-list
mailing list