Question about Pass-by-object-reference?

Steven D'Aprano steve at pearwood.info
Wed Jul 23 07:35:25 CEST 2014


On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote:

> fl <rxjwg98 at gmail.com> writes:
> 
>> On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:
>> > When you call a function, Python binds function parameter names to
>> > argument objects in the function's local namespace, the same as in
>> > name assignments. […]
>> > Nothing is being 'passed'.
>>
>> Thanks, but I don't understand your point yet. Could you give me
>> another example in which something is passed?
> 
> The point being made is that no values are is “passed” in a function
> call. If you have learned that term from elsewhere, it doesn't apply
> sensibly to Python.

Hmmm. I don't know that I like that. I think that these two sentences 
mean the same thing:

    "Call the function with x as argument."

    "Pass x to the function."

They both describe what is being done, only from slightly different 
points of view. In mathematics, to call a function is a completely 
abstract action. Magic happens, and a result is returned. But in 
programming languages, calling a function has concrete actions: certain 
things have to happen even before the function itself executes. What sort 
of things? Well, for starters, somehow the arguments need to be passed to 
the function, so that the function can tell the difference between being 
called with x as argument and being called with y as argument.

If you say "nothing is being passed", then my response would be "Oh, you 
aren't calling the function at all? Or just calling it with no arguments?"

I maintain that treating "call" and "pass" as more-or-less the same thing 
is common terminology, used throughout both mathematics and computing, 
and there's no very little benefit to avoiding it in the case of Python.



-- 
Steven



More information about the Python-list mailing list