Arnaud Delobelle wrote:
// What is passed to foo below is obviously not a 'variable // reference' as the argument is not a variable. foo(a[3]); // Now a[3] == 7 foo(b.i); // Now b.i == 7
Yes, it is. By "variable" I mean what C calls an lvalue, i.e. something you can assign to.
I'm not sure that your definition of 'call by value' is widely accepted. If it was, then this thread wouldn't exist.
It seems to be accepted by the Java and VB community, judging by what they refer to as call-by-value in those languages. You won't necessarily find it written down anywhere in the exact words I used. I have reverse-engineered it from the characteristics of a wide variety of languages that use the term call-by-value to describe one of their parameter passing mechanisms. Think of it as a theory that fits the observed linguistic facts.
(CBV) An evaluation strategy where arguments are evaluated before the function or procedure is entered. Only the values of the arguments are passed and changes to the arguments within the called procedure have no effect on the actual arguments as seen by the caller.
That hinges on what exactly is meant by "changes to the arguments". In Python it can only mean assigning directly to the bare name -- anything else isn't changing the argument itself, but something else to which the argument refers. -- Greg -- http://mail.python.org/mailman/listinfo/python-list