From: Steve Howell on 13 Feb 2010 21:54 On Feb 13, 6:41 pm, a...(a)pythoncraft.com (Aahz) wrote: > In article <hl6ilk$f7...(a)news.eternal-september.org>, > Alf P. Steinbach <al...(a)start.no> wrote: > > > > >My original statement, with reference to the Java language spec, > >didn't say much more about the language than that it has assignable > >references. > > Assuming this is what you're referring to: > > Python passes pointers by value, just as e.g. Java does. > > Then you are simply, completely, totally, and absolutely wrong. Period.. > Regardless of how CPython manages its state internally, Python as a > programming language does not have pointers. I agree with your statement for a suitably narrow definition of the words "pointer" and "have."
From: Steve Howell on 13 Feb 2010 22:04 On Feb 13, 6:10 pm, MRAB <pyt...(a)mrabarnett.plus.com> wrote: > Alf P. Steinbach wrote: > > * Steve Howell: > >> This thread is interesting on many levels. What is the core question > >> that is being examined here? > > > I think that regarding the technical it is whether a Python name refers > > to an object or not. I maintain that it does, and that the reference can > > be copied, and that the semantics of the language requires this and is > > defined in terms of this. Steve Holden, D'Aprano and many others > > maintain that there are no references, or that if there are then they're > > only an implementation aspect, i.e. that conceiveable one could have an > > implementation without them. > > > Regarding some other issues it seems to be a childish exercise in > > flaming, a flame war, with claims of insanity, incompetence, lying > > (that's actually from me, I reacted a bit strongly to faked quoting + > > conclusions from that in a posting not appearing on Usenet but on the > > Python mail list), etc. etc. ad nauseam, sprinkled with > > misrepresentations etc. I don't know the point of that. > > It's a pity that no-one has gone far enough to trigger Godwin's Law... > ;-) Godwin's Law need not be invoked here. The essential question is relevant and worthy of discussion, and most posters have presented intelligent, nuanced arguments even amidst all the needless flaming. It is actually a subtle point that I think people disagree on, whatever the extraneous personal baggage.
From: Alf P. Steinbach on 13 Feb 2010 22:44 * Aahz: > In article <hl6ilk$f7h$1(a)news.eternal-september.org>, > Alf P. Steinbach <alfps(a)start.no> wrote: >> My original statement, with reference to the Java language spec, >> didn't say much more about the language than that it has assignable >> references. > > Assuming this is what you're referring to: > > Python passes pointers by value, just as e.g. Java does. > > Then you are simply, completely, totally, and absolutely wrong. Period. > Regardless of how CPython manages its state internally, Python as a > programming language does not have pointers. The next paragraph was about the meaning of "pointer" in that first paragraph, referring to the Java language specification for the particular meaning here, namely a reference. Note: I did not refer to CPython, C, Pascal or whatever (but you mention CPython) for a meaning of "pointer". Instead I referred to the Java language specification for that meaning, where it's pretty clear: reference. So if you don't like the terminology, you can rephrase with perhaps more palatable terms: Python uses pass by sharing. References to objects are copied, the objects themselves are not copied. See <url: http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing> If you go to that URL, which isn't auhoritative but good enough, you find that "identical semantics in other languages such as Java and Visual Basic" Hence, your point is only a matter of terminology. The semantics /can/ be described using the term "pointer" (or for that matter the term "thingamajic"), when that term is suitably defined, and it /is/ described using that word for some languages. The language doesn't matter for the concept of pass by sharing. Hence, the terminological issue doesn't invalidate the description, as long as the terminology is clearly defined, as I did with ref to the Java lang spec. As you can see proper terminology reduces the size of explanation considerably, but as I see it that's not a big deal as long as the description is still /reasonably/ short. It does become a concern when the description runs to many pages of text. A simple thing should IMHO be simply described. But I think, as I've already stated several times up-thread, that "pointer" is a term best avoided for explanations within the Python community, even with a reference to a particular definition/usage, making the more verbose version in terms of "references" preferable for Python -- don't you agree? Cheers, - Alf
From: Steven D'Aprano on 13 Feb 2010 22:53 On Sat, 13 Feb 2010 18:54:34 -0800, Steve Howell wrote: > On Feb 13, 6:41 pm, a...(a)pythoncraft.com (Aahz) wrote: > > Regardless of how CPython manages its state internally, Python as a > > programming language does not have pointers. > > I agree with your statement for a suitably narrow definition of the > words "pointer" and "have." "Suitably narrow" is not that narrow. By no stretch of the imagination can one say that Python has a built-in pointer type analogous to pointers in (say) Pascal or C -- you can't usefully get the address of a variable (although the CPython implementation leaks the address of objects, it does so in a way that is safe and useless for everything but a label). There is no equivalent to (say) the Pascal program: program main(input, output); var x: integer; ptr: ^integer; begin x := 1; ptr := @x; ptr^ := ptr^ + 1; writeln(x); end. For a suitably wide definition of "pointer", then Python does have pointers: data = ['aaa', 'bbb', 'ccc', 'ddd', 'eee'] i = data.index('bbb') print data[i] i += 1 data[i] = 'zzz' but I trust that we all agree that describing the integer offset i above as a "pointer" is a reductio ad absurdum. -- Steven
From: Steve Howell on 13 Feb 2010 23:11
On Feb 13, 7:53 pm, Steven D'Aprano <st...(a)REMOVE-THIS- cybersource.com.au> wrote: > On Sat, 13 Feb 2010 18:54:34 -0800, Steve Howell wrote: > > On Feb 13, 6:41 pm, a...(a)pythoncraft.com (Aahz) wrote: > > > Regardless of how CPython manages its state internally, Python as a > > > programming language does not have pointers. > > > I agree with your statement for a suitably narrow definition of the > > words "pointer" and "have." > > "Suitably narrow" is not that narrow. By no stretch of the imagination > can one say that Python has a built-in pointer type analogous to pointers > in (say) Pascal or C -- you can't usefully get the address of a variable > (although the CPython implementation leaks the address of objects, it > does so in a way that is safe and useless for everything but a label). > There is no equivalent to (say) the Pascal program: > > program main(input, output); > var > x: integer; > ptr: ^integer; > > begin > x := 1; > ptr := @x; > ptr^ := ptr^ + 1; > writeln(x); > end. > > For a suitably wide definition of "pointer", then Python does have > pointers: > > data = ['aaa', 'bbb', 'ccc', 'ddd', 'eee'] > i = data.index('bbb') > print data[i] > i += 1 > data[i] = 'zzz' > > but I trust that we all agree that describing the integer offset i above > as a "pointer" is a reductio ad absurdum. > For a suitably wide definition of pointers CPython does indeed have pointers, and your example is only a weaker case of that truth. There is no reductio adsurbum. If I argued that CPython had curly braced syntax that would be absurd, since it is so concretely wrong. Pointers are a more abstact concept. |