anything like C++ references?
sismex01 at hebmex.com
sismex01 at hebmex.com
Tue Jul 15 01:30:15 CEST 2003
> From: Tom Plunket [mailto:tomas at fancy.org]
> Sent: Lunes, 14 de Julio de 2003 06:15 p.m.
> What I specifically want is a way to have a "second-level
> binding", e.g. a reference to a reference (assuming that the
> terminology is correct by saying that all Python variables are
> references). This is where I see the hole in Python, that there
> actually is a class of object that is different from everything
> else; you can bind to anything at all in the language...except
What for? What would be the practical use for such a thing?
To rebind a name remotely? It's not very consistent with the
rest of the language.
To have functions which rebind a name in a hidden way seems
to me like a veritable fountain of possible bugs. Explicit
is better than implicit and all that.
Those operations might have sense in a language where a variable
name is directly related to a storage location, a memory address;
but Python is not like that, and trying to program in that style
in Python is quite painful.
I find Python to be quite clear and powerful, and never have needed
such functionality in all the different type of projects I've done,
small-to-medium, but varied: SQL parsers, XML parsers, email
messaging systems, GUI frontends, RPC servers and clients,
text-formatting utilities, etc... I've never found a single
instance where I would have needed such that.
A binding can't also be a container, that's a job for an object,
if you truly need to "pull" data from a code segment, then you
should use a dictionary, or a list, or an instance of some
other mutable class, heck, even an empty class:
class Inbox: pass
IB = Inbox()
obj.value = 25
obj.message = "Here's a value for you"
Even a scheme as simpleminded as this is infinitely better than
having functions rebind your variable names to other objects,
even if they're the same class.
This, at least, is my opinion on the subject.
Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.
More information about the Python-list