anything like C++ references?

Adam Ruth owski at hotmail.com
Tue Jul 15 22:04:44 EDT 2003


In <qlq8hv8e7a5177o250c2fhvg9hv2lhfa15 at 4ax.com> Stephen Horne  wrote:
> On 15 Jul 2003 10:45:10 -0700, owski at hotmail.com (Adam Ruth) wrote:
> 
>>I came to Python from Ada, and all I have to say is:  Pointer-like
>>semantics are evil.  They're worse than goto's, they're deadly,
>>damaging, and should be avoided at all costs.
>>
>>They're an unhappy necessity, akin to stop-lights.  You need them
>>because roads intersect, but if roads don't intersect, don't use them!
> 
> Absolutely true. And the worst thing you can do when you really can't
> avoid pointers is to obscure the issue even more by disguising them as
> something else.

I assume that you're referring to people 'faking' pointer in Python (
such as wrapping variables in lists, etc.)  I'd ammend your statement to 
say:  

And the worst thing you can do is to obscure the issue even more by 
disguising them as something else, WHEN YOU DON'T REALLY HAVE TO.

In Python, there is no situation where "you really can't avoid pointers".  
It's only when you program C or C++ in Python that you think you can't 
avoid pointers.  There are much better idioms to achieve the desired 
results.

> The biggest problems with pointers relate to things with pointer math,
> pointers to deleted objects etc. These things need not exist in a
> scripting language that provides pointers - pointers don't have to be
> implemented using store addresses. That is just a concept from C, C++,
> Pascal, Ada etc - not something I want to see imitated. If pointers
> can be created that refer to given objects, and if pointers can be
> dereferenced, that is actually enough to support indirect referencing.

It's actually also unnecessary in Python.

Adam Ruth 




More information about the Python-list mailing list