What other languages use the same data model as Python?

Hans Georg Schaathun hg at schaathun.net
Wed May 4 06:56:16 EDT 2011


On Wed, 4 May 2011 02:56:28 -0700 (PDT), Devin Jeanpierre
  <jeanpierreda at gmail.com> wrote:
:  Eh, that example doesn't say what you think it does. It has the same
:  behavior in C: http://ideone.com/Fq09N . Python is pass-by-value in a
:  meaningful sense, it's just that by saying that we say that the values
:  being passed are references/pointers.

No, Python is not pass-by-value, because the pointer is abstracted 
away.  You transmit arguments by reference only and cannot access the
value of the reference.  In C it is pass by value, as the pointer 
is explicit and do whatever you want with the pointer value.  

So, even though you have the same mechanism in C and Python, they
do not have the same name.  In the low-level C you only have pass
by value, but you can use the pointer syntax to do whatever you want
within pass by value.  In the higher-level python, you do not have 
the flexibility provided by explicit pointers, so you need to explain
the semantics without having a pointer concept defined a priori.

:                                        This is maybe one level of
:  abstraction below what's ideal, but Scheme, Java, etc. share this
:  terminology. (Ruby calls it pass-by-reference AFAIK. Whatever, a rose
:  by any other name...)

Now, this is confusing, because the terminology is not universal and
hardly intuitive.  What is called transmission by reference in a
Simula context (Bjørn Kirkerud's textbook on OO Programming with Simula
for instance) is called object sharing in Wikipedia.  What Wikipedia
calls call by reference is transmission by name in the Simula context.

-- 
:-- Hans Georg



More information about the Python-list mailing list