anything like C++ references?

Stephen Horne intentionally at blank.co.uk
Tue Jul 15 00:27:05 EDT 2003


On Mon, 14 Jul 2003 18:30:15 -0500, sismex01 at hebmex.com wrote:

>> 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
>> references.
>> 
>> -tom!
>>
>
>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.

Absolutely. At present, people fake it by abusing mutable types. Or
else they fall over it when they are surprised by the behaviour of
mutable types. Wouldn't it be better if it was explicit? Wouldn't it
be better if it only happened when you actually asked for it?

>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:

Really. Is that what dictionaries are for? Or lists? Or other mutable
classes?

Or are you abusing the functionality of types intended for a different
purpose in order to fake pointers?





More information about the Python-list mailing list