What other languages use the same data model as Python?

Hans Georg Schaathun hg at schaathun.net
Wed May 4 16:20:54 EDT 2011


On Wed, 04 May 2011 14:33:34 -0500, harrismh777
  <harrismh777 at charter.net> wrote:
:  Hans Georg Schaathun wrote:
: > In C it is pass by value, as the pointer
: > is explicit and do whatever you want with the pointer value.
: 
:  You clearly are not a C programmer.

I am not really a programmer period.  I am many things and run
into programming from many more angles than a typical programmer 
does.  And as to C, I no longer use C when I can avoid it (which 
I can most but not all of the time).

A few words are missing though.  C is semantically pass by value.
Always.  But because you have pointers are data object, you can do 
whatever you want with them, and pass a pointer by value.  Thus you
can achieve the effect of transmission by reference or by name, if 
you want to.

:  Most of my C data abstractions use dual circular linked lists of 
:  pointers to structures of pointers. *All* of that is only ever passed 
:  (at least in my programming) as references. My code almost never passes 
:  data by value.

Not if you do not consider pointers as data, but C does, in the sense 
that pointers can be manipulated in the same ways as any other kind of
data.

:  We do not consider passing a pointer as *by value* because its an 
:  address; by definition, that is pass-by-reference. We are not passing 
:  the *value* of the data, we are passing the memory location (the 
:  reference) to the data. Pass by *value* on the other hand actually 
:  places the *value* of the data item on the call stack as a parameter.

That is a useful viewpoint, but it falls a bit short when you need
to explain how to deal with pointers to pointers to pointers.  Pointers
in C are objects.

But mind you, I was not the one to suggested to refer to this 
as pass by value.  I was explaining why it makes more sense to 
do so for C but not for Python.

You simply end up with different wordings if you try to explain how
C works, and how to model data in C.  We can both be right, you know;
we are just addressing the issues at different levels of abstraction.

:  Much of this conversation has more to do with semantics.

Of course.  The concepts are used to explain the semantics of the
languages.  



-- 
:-- Hans Georg



More information about the Python-list mailing list