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

Steve D'Aprano steve+python at pearwood.info
Sun Sep 24 10:49:02 EDT 2017


On Mon, 25 Sep 2017 12:35 am, Stefan Ram wrote:

>   WRT to assertions about Python, I try to base them on the
>   "The Python Language Reference, Release 3.6.0" (PRL).
> 
>   So, WRT to parameter passing, I would use this part of the PRL:
> 
>       »The following constructs bind names: formal parameters
>       to functions,« PRL 4.2.1
> 
>   . Therefore, what Python does, I'd call »call by binding«.

I am not aware of "call by binding" being a well-known or recognised term. Did
you make it up?

Also, the problem is that *any* form of function call binds *something* to the
function parameters. If we consider the Pascal declaration:

procedure proc(x: integer; var y: integer);


and then we call it:

var
  a, b: integer;
begin
  a := 1;
  b := 2;
  proc(a, b);
end.


then 1 is bound to x and 2 is bound to y. They happen to exist in different
scopes (x is local to proc, the *name* y is local to proc, but the variable is
bound to y is global) but that's not important.

The point I am making is that we could describe just about any and all languages
with functions "call by binding", whether they are call by value like C, call
by reference like Fortran, call by need like Haskell, or call by sharing like
Python.



-- 
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