En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke <and...@acooke.org>
escribió:
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
use).
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.
because:
(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).
But -paraphrasing A.E.- we should explain it in the simplest terms, but
not simpler.
Some people think that there exist only two possible ways to pass an
argument: by value or by reference. The way Python does it doesn't have
the same properties that pass-by-value nor pass-by-reference have in other
languages, so both names are inapropiate. You appear to favor the "by
reference" name. A couple months ago some other guy were strongly
defending the "by value" name -- he even set up a website supporting his
idea.
The fact is, if you say "it's by value" you'll disappoint some
expectations from some users, and if you say "it's by reference" you'll
disappoint some other expectations. So you must say something different
("it's by reference, but the references cannot be modified (!), and...",
"it's by value, but the values are references (!!), and...", or whatever
description you choose). Given that, it's better to use a different name:
you're going to explain the concept anyway.
And Python isn't the first language using this convention; if you look in
the FAQ or search recent threads in this group you'll find references
going back to the '70s.
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list