osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tutor] beginning to code


Op 2017-09-23, Rick Johnson schreef <rantingrickjohnson at gmail.com>:
> These pissing contests over how values are passed in Python
> are totally irrelevant. What does it matter? Nothing will be
> gained or lost by arguing over which is true, or not. Unless
> the distinction is preventing you from doing something that
> you'd like to do, or unless you want to argue that one
> "value passing method" would bring X, Y or Z benefits over
> the other, what does it matter?

Amen.

For what it's worth, this discussion lead me to do a bit of historical
research into how these terminologies came to be (also to see if there
is some sort of "official" definition of what they actually mean).

The earliest to which I can trace the discussion is on the context of
the definition of the Algol programming language. Algol had both
"call by value" and "call by name".

Then the whole "call by XXX" terminology took off and people started
talking about "call by copy in/out" and whatever. The "call by
reference" terminology was introduced to describe what Fortran had been
doing all along.

The CLU people (primary Barbara Liskov) introduced "call by object
sharing", to describe what CLU did. This matches pretty well what Python
does, and what Java does, and what basically every programming language
invented in the last 25 years does.

Now, as I said, what Java and what CLU do is pretty similar, but in
the Java community this very same thing is called "call by value".
As far as I can follow, this is for the following reason:

 * The Algol report invented "call by value" and "call by name" and was
   very influential.

 * In particular, the Report on the Scheme language was heavily
   influenced by the Algol report. In the Scheme report, Scheme is
   described as being "call by value", again probably because of
   influence of the Algol report, and Scheme is definitely NOT
   "call by name". Note that in our terminology, Scheme should
   properly be called "call by object [sharing]".

 * Guy Steele, who was involved in the Scheme standard, then went 
   on to work on the Java language definition.

So Java got its terminology from the Algol->Scheme->Java route.
Python got it from CLU.

As an aside, in the academic literature, "call by value" is almost
always contrasted with "call by name" (nobody seems to have ever
published a paper discussing "call by reference").
Typically, this comparison is done in calculi which even lack
assignment so that the difference between call by value and call by
reference would be unobservable anyway.

Stephan