Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'essentially': 0.04; 'languages,': 0.04; 'yet.': 0.04; 'argument': 0.05; 'cpython': 0.05; 'assignment': 0.07; 'returned.': 0.07; 'subject:Question': 0.07; '22,': 0.09; 'function,': 0.09; 'happens.': 0.09; 'parameter': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; '*i*': 0.16; '...,': 0.16; 'argument,': 0.16; 'assignments.': 0.16; 'bind': 0.16; 'bound.': 0.16; 'does,': 0.16; 'elsewhere,': 0.16; 'finney': 0.16; "function's": 0.16; 'magic': 0.16; 'namespace,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'sense,': 0.16; 'subject:object': 0.16; 'language': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'slightly': 0.19; '>>>': 0.22; 'example': 0.22; 'programming': 0.22; 'header:User- Agent:1': 0.23; 'references': 0.26; 'second': 0.26; 'values': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'am,': 0.29; 'points': 0.29; "doesn't": 0.30; 'member.': 0.30; 'that.': 0.31; '>>>>': 0.31; "d'aprano": 0.31; 'names.': 0.31; 'steven': 0.31; 'terms.': 0.31; 'view.': 0.31; 'writes:': 0.31; 'themselves': 0.32; 'another': 0.32; 'call.': 0.33; 'level.': 0.33; 'could': 0.34; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'done,': 0.36; 'false': 0.36; 'leads': 0.36; 'view,': 0.36; 'subject:?': 0.36; 'two': 0.37; 'being': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'address.': 0.39; 'received:org': 0.40; 'how': 0.40; 'simply': 0.61; 'first': 0.61; 'name': 0.63; 'term': 0.63; 'such': 0.63; 'july': 0.63; 'different': 0.65; 'jul': 0.74; 'action.': 0.84; 'end.': 0.84; 'received:fios.verizon.net': 0.84; 'sensibly': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Question about Pass-by-object-reference? Date: Wed, 23 Jul 2014 18:51:47 -0400 References: <9219a041-0d6f-4e90-b209-5fd7c50ae1fd@googlegroups.com> <53cf499c$0$29897$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <53cf499c$0$29897$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406155927 news.xs4all.nl 2865 [2001:888:2000:d::a6]:52232 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75101 On 7/23/2014 1:35 AM, Steven D'Aprano wrote: > On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote: > >> fl 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. [=E2=80=A6] >>>> Nothing is being 'passed'. Non-human implementations copy object ids, but I was not writing at that = level. >>> 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 =E2=80=9Cpassed=E2=80=9D= 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." I disagree. In Python, when one calls the function with an argument,=20 computer implementatipns 'pass' an object reference, which in CPython is = an object address. Conflating the two sentences above leads people to=20 claim that python 'calls by (object) reference'. In a sense, it does,=20 But thinking in those terms often leads to false inferences about how=20 Python behaves. So I think it better not to think is such terms. > They both describe what is being done, only from slightly different > points of view. 'Passing' is an implementation of calling. I have little idea what *I*=20 do when interpreting a function call while interpreting python code. > In mathematics, to call a function is a completely > abstract action. Magic happens, and a result is returned. From a set theory point of view, nothing happens. The result simply is=20 the second member of the pair with the argument as the first member. > But in programming languages, calling a function has concrete actions:= The *essential* concrete action is the binding of something to parameter = names. 'Passing' is a means to that end. What matters is what gets=20 bound. In Python, python objects themselves get bound. And the binding=20 is essentially the same as in assignment statements. Other language bind = values or references or pointers or ..., with different consequences. --=20 Terry Jan Reedy