What other languages use the same data model as Python?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 5 11:42:58 EDT 2011


On Thu, 05 May 2011 07:43:59 +1000, Ben Finney wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> 
>> Given the following statement of Python code:
>>
>> >>> x = "spam"
>>
>> what is the value of the variable x?
> 
> Mu (無).
> 
> ‘x’ is a name. Names are bound to values. Talk of “variable” only
> confuses the issue because of the baggage carried with that term.

Yes, good point. Consider me chastised, because I actually knew that. 
It's just that the term "variable" is so useful and so familiar that it's 
easy to use it even for languages that don't have variables in the C/
Pascal/Fortran/etc sense.


> But the data model of Python doesn't fit well with the ideas that the
> term “variable” connotes for most programmers: a box, perhaps of a rigid
> shape (data type) or not, which is labelled ‘x’ and nothing else. For
> another variable to have an equal value, that value needs to be copied
> and put in a separate box; or perhaps some special reference to the
> original needs to be made and placed in a box.
> 
> Saying “variable” and “has the value” just invites baggage needlessly,
> and creates many assumptions about Python's data model which has to be
> un-done, often after much false mental scaffolding has been built on
> them by the newbie and needs to be dismantled carefully.

I've quoted your two paragraphs because I think they're very important, 
not because I intend arguing. Possibly a first for me :)

However.... 

> Python isn't pass by anything. Nothing gets copied, nothing gets passed;
> when a function is called with an object as a parameter, the object
> stays put, and simply gets a new temporary name bound to it for the
> function's use.

This, however, is incorrect. "Passing" in this sense refers to calling 
the function with an argument, hence "pass by..." and "call by..." are 
synonyms. The mechanics of how the compiler or interpreter makes 
arguments available to functions has real consequences at the language 
level: the calling strategy used by the compiler effects the language 
semantics.


>> > Whatever, a rose by any other name...)
>>
>> Do you really think that roses would be the symbol of romantic love if
>> they were called "disgusting stink-weeds of perversion and death"?
> 
> Juliet's point stands, though: they would still smell as sweet, and the
> term you describe would be unlikely to catch on since it doesn't
> describe them well at all.

Perhaps a counter-example is that of the tomato, which never took off as 
a food in Europe until people stopped calling them "love apples", and 
thinking that they were deadly poison.

Or Chinese Gooseberries, better known by the name thought up by a 
marketing firm, "kiwi fruit".


-- 
Steven



More information about the Python-list mailing list