call-by-reference (was Re: Any other Python flaws?)

David C. Ullrich ullrich at math.okstate.edu
Sat Jun 16 09:52:57 EDT 2001


On 15 Jun 2001 19:20:53 GMT, m.faassen at vet.uu.nl (Martijn Faassen)
wrote:

>David C. Ullrich <ullrich at math.okstate.edu> wrote:
>> On 15 Jun 2001 14:08:58 GMT, jcm <grumble at usa.net> wrote:
>
>>>Martijn Faassen <m.faassen at vet.uu.nl> wrote:
>>>
>>>> I agree that nobody agrees on whatever 'call-by-reference' means, or what
>>>> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't
>>>> support call-by-value while Python apparently does. :)
>>>
>>>In my experience, there's good agreement about what call-by-reference
>>>means just about everywhere but in newsgroups.  Python supports only
>>>call-by-value -- you can't change the value of a variable in your
>>>caller's scope (globals aside).
>
>> It's call-by-value all right. The confusion is caused
>> by the fact that the values are references. But passing
>> a reference "by value" is not a call by reference.
>
>I think the confusion makes it not worth saying things like "It's simple!
>Python does call-by-value only!". :) Better be more specific about the
>behavior.

Me, I'd never say _anything_ was simple. Too dangerous.

(Yes, it probably is better to be specific. But while some
confusion may be reasonable I really don't think there's
any _ambiguity_ - it really is call by value. For example
cf recent questions about why there's no swap() function...)

>Regards,
>
>Martijn
>-- 
>History of the 20th Century: WW1, WW2, WW3?
>No, WWW -- Could we be going in the right direction?



David C. Ullrich
*********************
"Sometimes you can have access violations all the 
time and the program still works." (Michael Caracena, 
comp.lang.pascal.delphi.misc 5/1/01)



More information about the Python-list mailing list