Hrvoje Niksic a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> > writes: > >>> It seems to me that in recent times more Python beginners come from >>> a Java background than from a C one. >> Java does have "container" variables for primitive types, and even >> for "references", Java's variables are more than names - they do >> hold type informations too. Now I don't pretend to know how this is >> really implemented, but AFAICT, and at least from a cognitive POV, >> Java's variables model looks very close to the C/C++ model. > > While Java's variable declarations bear a superficial (syntactical) > similarity to C, their semantics is in fact equivalent to the > object-reference semantics we know in Python. They implicitly refer > to objects allocated on the heap and, just like in Python, the same > object can be referenced by multiple variables.
You're talking about reference types here - not primitive types. And even then, from what I remember (not having done any Java these last 4 years at least), Java's reference types are much closer to C++ references than to Python. > If Java's model were > close to C/C++, that would not be possible without explicit > pointers/references The reference is implicit for non-primitive types. > since an object would be "contained" by the > variable. > > Variables holding primitive types don't really influence the > variable/object relationship, since the values they hold are by nature > immutable and without identity. Python's immutable types instances does have an identity, and follow the same rules as mutable types instances - mutability set aside of course. Which is not the case with Java, where primitive types and reference types follow distinct rules. I'll check this out (not having done Java for a couple years) and come back, but I certainly remember Java's model as being way closer to C++ than to Python. -- http://mail.python.org/mailman/listinfo/python-list