anything like C++ references?

Michael Chermside mcherm at mcherm.com
Thu Jul 17 08:43:54 EDT 2003


Adam Ruth writes:
> You are correct in that there are times when pointer semantics would be 
> somewhat useful, but they're never necessary.  His statement was that 
> there are time that "you really can't avoid pointers".  That's not true.  
> I definitely went a little overboard, and it sounds like I'm saying, 
> "not only are pointers not necessary, they're never desirable".  My tone 
> was a bit more knee jerk than was prudent.

So it sounds like we ALL agree: (1) pointers are never *necessary*, and
(2) they're sometimes useful.

Adam Ruth writes:
> Your code example isn't really about pointers, though, as the C++ 
> version doesn't use pointers.

You're right... poor example. In my effort to simplify (and remember)
the example, I left out the fact that the function "makeNewComplexObject"
in this case) was responsible for incrementing i and sometimes didn't
increment it. Frankly, it was a messy piece of C++ code and I wouldn't
have done it that way in Python except that it was useful to translate
more-or-less directly from the working C++. And I used it as an example
because it was the only time I could think of (in real code) where I
used the "one-item-list as a fake pointer" idiom in Python. (Although
I've needed it in Java quite often.) Which goes to support your point
that Python's design makes the pointer thing useful much less often.

Adam Ruth writes:
> I would be interested in seeing a more complex example where something 
> would be substantially cleaner with pointers.  I have to acknowledge the 
> possibility that they exist, I don't know everything... yet :)

Good point. I think you should be granted a default judgement... it's
now up to pointer proponants (who are they?) to show a case where
"pointers" really are useful in Python.[1] I tried, and my example hasn't
even convinced myself.

-- Michael Chermside

[1] Python with Horne-style parameter passing obviously needs pointers,
    but that's not the question here, since that language doesn't
    exist!






More information about the Python-list mailing list