From: Alf P. Steinbach on 8 Feb 2010 00:18 * Steven D'Aprano: > On Mon, 08 Feb 2010 03:21:11 +0100, Alf P. Steinbach wrote: > >>> A pointer tells you where something is; a reference doesn't. >> Sorry, I don't know of any relevant terminology where that is the case. > > Taken from Wikipedia: > > "A pointer is a simple, less abstracted implementation of the more > abstracted reference data type (although it is not as directly usable as > a C++ reference)." > > http://en.wikipedia.org/wiki/Pointer_(computing) > > In other words, a pointer is a specific type of reference. A reference in > turn is an opaque but low-level data type which "refers to" in some way > to the data you actually care about. (C++ has a concrete reference type, > which is not to be confused with abstract references.) > > http://en.wikipedia.org/wiki/Reference_(computer_science) > > Unless otherwise stated, references are opaque and coders need not care > how the reference mechanism is implemented, see e.g.: > > http://www.cocoabuilder.com/archive/cocoa/20777-opaque-reference.html > > In Python you don't use references directly, there is no reference type > or object. You can simulate the semantics of references (but not > pointers) by putting your object in a list and passing the list around. Yes, sort of. The last paragraph however confuses two different meanings of "reference". So when using terms such as "reference" it helps to refer :-) to some specific terminology, unless that's clearly understood from context. Cheers, - Alf
From: Arnaud Delobelle on 8 Feb 2010 02:19 "Alf P. Steinbach" <alfps(a)start.no> writes: > * Chris Rebert: >> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything(a)gmail.com> wrote: >>> Ok, just looking for a sanity check here, or maybe something I'm >>> missing. I have a class Test, for example: >>> >>> class Test: >>> def __init__(self, param1, param2, param3): >>> self.param1 = param1 >>> self.param2 = param2 >>> self.param3 = param3 >>> >>> Next, I have a dictionary mytest that contains instances of Test. If >>> I want to modify one of the Test instances within my dictionary, I >>> have to rewrite the entire entry, correct (since Python passes by >>> value, not reference)? >> >> Incorrect; Python uses neither. See >> http://effbot.org/zone/call-by-object.htm for a excellent explanation >> of what Python does use. > > Hm. While most everything I've seen at effbot.org has been clear and > to the point, that particular article reads like a ton of obfuscation. > > Python passes pointers by value, just as e.g. Java does. Please! Not this again! This has been discussed to death and beyond more than enough times. Go search the c.l.p archives, read it all, and I'm sure you won't want to add anything anymore. -- Arnaud
From: Gerard Flanagan on 8 Feb 2010 03:02 Arnaud Delobelle wrote: > "Alf P. Steinbach" <alfps(a)start.no> writes: > >> * Chris Rebert: >>> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything(a)gmail.com> wrote: >>>> Ok, just looking for a sanity check here, or maybe something I'm >>>> missing. I have a class Test, for example: >>>> >>>> class Test: >>>> def __init__(self, param1, param2, param3): >>>> self.param1 = param1 >>>> self.param2 = param2 >>>> self.param3 = param3 >>>> >>>> Next, I have a dictionary mytest that contains instances of Test. If >>>> I want to modify one of the Test instances within my dictionary, I >>>> have to rewrite the entire entry, correct (since Python passes by >>>> value, not reference)? >>> Incorrect; Python uses neither. See >>> http://effbot.org/zone/call-by-object.htm for a excellent explanation >>> of what Python does use. >> Hm. While most everything I've seen at effbot.org has been clear and >> to the point, that particular article reads like a ton of obfuscation. >> >> Python passes pointers by value, just as e.g. Java does. > > > Please! Not this again! This has been discussed to death and beyond more > than enough times. Go search the c.l.p archives, read it all, and I'm > sure you won't want to add anything anymore. > +1 !!
From: Steve Holden on 8 Feb 2010 06:51 Steven D'Aprano wrote: > On Sun, 07 Feb 2010 22:03:06 -0500, Steve Holden wrote: > >> Alf: >> >> This topic was discussed at great, nay interminable, length about a year >> ago. I'd appreciate it if you would search the archives and read what >> was said then rather than hashing the whole topic over again to nobody's >> real advantage. > > Curse you Steve, I had just come up with a brilliant rebuttal of Alf's > position. It was sheer genius, the sort of thing that would have James > Gosling weeping with envy. > > Oh well, into the bitbucket it goes... > > You're a better man for it, Steven! Admirable self-restraint ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/
From: Steve Holden on 8 Feb 2010 06:59
Alf P. Steinbach wrote: > * Steve Holden: [...] >> Alf: >> >> This topic was discussed at great, nay interminable, length about a year >> ago. I'd appreciate it if you would search the archives and read what >> was said then rather than hashing the whole topic over again to nobody's >> real advantage. > > Well that's my point, and thanks for backing me up on that :-): it's > very simple, and as demonstrated can be expressed in 10 words or less > (plus perhaps a terminology reference, as I did above), so all that > discussion and in particular the lengthy article at effbot serves as > obfuscation and nothing else. > Please don't assume I was trying to support you. Your remarks showed considerable ignorance of issue that were extremely nuanced. Whatever point you were trying to make was lost in your self-aggrandizing disrespect of Fredrik Lundh, a software engineer of some repute with a long history of contribution to Python. The fact that your post was basically a restatement of one of the several competing positions in that thread makes it no more right than any of the others. > By the way, most every programming language has some corner like that, > something that is utterly simple but somehow has some kind of > obfuscation-meme attached. > Why thank you for the education. Somehow in my 40-odd years of programming I had quite overlooked that fact. Which helps how? > In C++ it's "call" and "constructor". It doesn't help that the > language's standard lays down the law on it, it doesn't help that the > language's creator has laid down the law, it doesn't help that it's > utterly and completely simple. Somehow newbies and even some experienced > people manage to create their own terminological nightmare and drawing > conclusions about reality from that misguided obfuscated view, and then > discussing it up and down and sideways. > Which IMHO you have done little to assist. Just how exactly *do* we succeed in asking you not to discuss something? yours intemperate-ly - steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/ |