Closures in leu of pointers?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Jun 29 14:51:35 EDT 2013


On Sat, 29 Jun 2013 19:02:01 +0200, Antoon Pardon wrote:

> Op 29-06-13 16:02, Michael Torrie schreef:
>>
>> The real problem here is that you don't understand how python variables
>> work.  And in fact, python does not have variables.  It has names that
>> bind to objects.
> 
> I don't understand why members of this list keep saying this. Sure the
> variables in python behave differently than those in C and algol  But
> they behave similarly as those in smalltalk and lisp and I haven't seen
> anyone claim that smalltalk and lisp don't have variables.
> 
> We might as well say that C doesn't have variables, it has names
> pointing to memory locations or value containers or something like that.
> 
> AFAICS there is no reason why "variable" wouldn't be appropiate for
> python names as opposed to C names.

You are absolutely correct in principle. But in practice, there are ten 
bazillion C, Pascal, COBOL, and BASIC programmers who understand the word 
"variable" to mean a named memory location, for every Smalltalk or Lisp 
programmer who understands a "variable" as a name binding. So it's pure 
weight of numbers thing.

The average Lisp programmer will be completely aware that "variable" can 
mean various things, and take care to determine what the word means in 
Python. She will immediately grok what we mean, even if she thinks that 
the "no variables" part is just an affectation ("Heh, those wacky Python 
dudes think they don't have variables!") but at least she'll understand 
the name binding part.

On the other hand, the average C programmer is barely aware that there 
are other languages at all, let alone that some of them differ from C in 
semantics as well as syntax. So by emphasising the differences ("Python 
has no variables? It has name bindings?") we increase the likelihood that 
he'll learn the differences in semantics as well as syntax.

So, in a very practical sense, "Python has no variables, it has name 
bindings" is completely wrong except in the sense that really matters: 
Python's variables don't behave identically to C variables.


-- 
Steven



More information about the Python-list mailing list