Reference or Value?
andrew at acooke.org
Tue Feb 24 09:44:01 CET 2009
Steven D'Aprano wrote:
> On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote:
>> Steven D'Aprano wrote:
>>> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote:
>>>> as far as i understand things, the best model is:
>>>> 1 - everything is an object
>>>> 2 - everything is passed by reference
>>> Except that is wrong. If it were true, you could do this:
>> [pointer swapping]
>> i was thinking of how the stack is used; i would have called what you
>> are talking about "pointer semantics". however, on reading around a
>> little, it seems that i'm in a very small minority (which is a pity,
>> because if you restrict the meaning to how values are handled on the
>> stack then you get a lot closer to having just values and references,
>> rather than the whole pile of different terms that are apparently in
>> sorry for the confusion,
> Why is it a pity to have a whole pile of different terms to describe a
> whole lot of different behaviours? I would suggest the real confusion
> would be if we had two terms to describe a dozen different parameter-
> passing conventions.
(1) it's often useful to explain things as (simpler) orthogonal components
rather than globbing everything under one term; that lets you more easily
carry across knowledge from previous experience.
(2) while using a term that has (according to wikipedia) "widespread usage
in the Python community" helps you save time and avoid confusion, it
doesn't necessarily explain best to someone from outside that community
what is happening. in this particular case you are getting dangerously
close to having a term that is used only for one language and which,
therefore, is at risk of meaning little more that "the way python does it"
(which is, i think you'll agree, more tautological than helpful).
More information about the Python-list