Call by binding [was Re: [Tutor] beginning to code]

Steve D'Aprano steve+python at pearwood.info
Sun Sep 24 21:38:01 EDT 2017


On Mon, 25 Sep 2017 08:39 am, Gregory Ewing wrote:

> Dennis Lee Bieber wrote:
>> "Binding" itself tends to be Python specific terminology -- in that it

"Binding" is certainly not Python-specific:

https://en.wikipedia.org/wiki/Name_binding

and here's an example of the term in use:

https://www.gnu.org/software/sather/docs-1.2/tutorial/fortran-names.html


>> is the parameter /name/ that gets bound/attached to the argument /object/.
>> It is the same method as used in any Python "assignment" statement,
> 
> Which is why I think "call by assignment" would be
> a much better term!

I think that suffers from the same problem as "call by binding" -- assignment is
too general a word.

The Pascal assignment:

a := b;

copies the value of b to the storage position represented by a. That's precisely
the same thing that occurs when you call func(b), so one might equally say that
Pascal was call by assignment. Likewise for C assignment.

Pascal doesn't have "reference variables", so there is no assignment analogue to
calling a function with a var parameter. But C++ does have reference variables,
to we can say that assignment:

a = b;

is the same as function call func(b) regardless of whether C++ is using by-value
or by-reference semantics.


So I believe that either "call by binding" or "call by assignment" could both
equally apply to any and all languages with function parameters, regardless of
implementation or the language's defined semantics.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list