anything like C++ references?
intentionally at blank.co.uk
Wed Jul 16 23:16:24 CEST 2003
On Wed, 16 Jul 2003 19:06:40 +0000 (UTC), Adam Ruth
<owski at hotmail.com> wrote:
>In <mailman.1058377226.21359.python-list at python.org> Michael Chermside
>> Look, first of all, let me say that I disagree with Stephen Horne in
>> this discussion. Or, to be more precise, I think that the approach he
>> is using is not one which is useful in describing Python. HOWEVER,
>> that doesn't mean that there's NOTHING to what he is saying, and your
>> claim that there is no situation requiring "pointers" in Python seems
>> wrong to me.
Thankyou - nice to know I'm not *completely* insane ;-)
>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".
Hmmm - those words were in a context. I never claimed that "you really
can't avoid pointers" in *current* Python - that's obviously not true.
But if the copy-on-write stuff were implemented, the need would arise.
>>> class c :
... x = 0
>>> k = c()
>>> def fn(a) :
At the moment, the result is 1. With copy-on-write, object parameters
would behave exactly the same as integer or other immutable
parameters. The result would be 0. You'd need pointers or references
or call-by-reference to do a number of things.
>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.
Then I withdraw certain comments I've made. I really can't complain
about people going "a little overboard", can I ;-)
>This is just as clear as the C++ version, and more clear than the Python
>version that wraps with the list.
>This example, though, doesn't really show the difference, it's too
>trivial. All of the versions are clear enough, with the difference
I agree with both of these comments.
>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 :)
I was told today that both Perl and ML have something equivalent to
pointers. I don't know either language, though. Given the current
audience, mentioning Perl may be a mistake - but we could look up the
rationale for including them in ML.
That is something to do with caution, though. I imagine that ML is a
very different language to Python. I have used Haskell and Miranda,
which are at least broadly the same paradigm but may or may not be
quite a similar languages, but even those I never exactly knew well.
The rationales might not be very portable.
More information about the Python-list