anything like C++ references?
Erik Max Francis
max at alcyone.com
Tue Jul 15 07:08:29 CEST 2003
Stephen Horne wrote:
> If people are routinely faking the abstraction, maybe that is because
> it is a useful abstraction to have. Maybe it would be better to
> support it explicitly instead of forcing people to use tricks and
But the issue I'd raise is why you think that modification of an object
in a mutable container is "faking the abstraction." C and C++ have the
concept of a pointer, and that's well and good for those languages.
Python doesn't, and doesn't need it. If you want the effect of a C or
C++ pointer in Python, you can get it through very simple means. The
reason why it's not necessary is that, as has been pointed out,
essentially _all_ "variables" in Python are references/pointers -- they
refer, perhaps non-uniquely, to objects which have identity beyond the
references that have them. This isn't the best way to explain how
Python's variable system works to newbies, because it introduces
confusion (it's not quite call by value and it's not quite call by
reference; it's call by value where the values are references), but any
variable "points" to a reference.
The equivalent concept to what you're getting at is one of mutability,
and that is handled utterly distinctly than it is in C or C++. Someone
familiar with Python might argue that it's C++ that's "faking the
abstraction," not the other way around.
They're very different ways of doing things; insisting that the square
peg should be rounded worries people who liked the square hole just
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ The actor is not quite a human being -- but then, who is?
\__/ George Sanders
More information about the Python-list