nonlocal fails ?

Chris Angelico rosuav at gmail.com
Fri Nov 15 14:22:41 EST 2019


On Sat, Nov 16, 2019 at 6:20 AM Luciano Ramalho <luciano at ramalho.org> wrote:
>
> Re: the whole pass by reference discussion.
>
> I've seen Python's argument passing described as "call by value,
> except that all values are references". This makes sense, but is
> confusing.

That's the typical sort of description you get from someone who mostly
understands Python's semantics, but is hung up on the idea that
everything is either call-by-value or call-by-reference, and is trying
to figure out which box Python fits into.

> Michael Scott, in his textbook Programming Language Pragmatics (4e)
> terms the Python way "call by sharing". That is the same mode used in
> most OO languages that don't have pointers, including Ruby, SmallTalk,
> and Java (this applies to Java reference types; primitive types use
> call by value). Call by sharing means that each formal parameter of
> the function gets a copy of each reference in the arguments.
>

I don't think anyone's yet linked to this:

https://nedbatchelder.com/text/names1.html

ChrisA


More information about the Python-list mailing list