On 2011-05-03, Hans Georg Schaathun <h...@schaathun.net> wrote: > On 01 May 2011 08:45:51 GMT, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >: Python uses a data model of "name binding" and "call by object" (also >: known as "call by sharing"). I trust I don't need to define my terms, but >: just in case: > > Without having the time to get my hand around exactly what this means: > Simula has three ways of transmitting arguments, namely transmission > by name, by value, and by reference. Is transmission by name the same > as call by object?
No. For example, assume the argument is a[i]. In call by object, the expression a[i] is evaluated (i is evaluated, and then used as an index to determine the object that is the ith element of a). The callee's argument name is then bound to that object. In call by name, every time the callee references the argument name, the expression a[i] is evaluated anew. If the value of 'i' or the binding of 'a' has changed since the time of the function call, then the callee's argument now refers to a different object than it did at the time of the the function call. It's rather like a macro language (e.g. cpp) which merely performs a textual substitution of the argument name (the difference between pass-by-name and macro substitution is that the context of the argument evaluation is different). -- Grant Edwards grant.b.edwards Yow! Well, I'm INVISIBLE at AGAIN ... I might as well gmail.com pay a visit to the LADIES ROOM ... -- http://mail.python.org/mailman/listinfo/python-list