Re: On Call By Value



Hamish Reid wrote:
In article <_9adnR3mCPWS4nPUnZ2dnUVZ8u2dnZ2d@xxxxxx>,
Richard Heathfield <rjh@xxxxxxxxxxxxxxx> wrote:

Hamish Reid said:

The recent thread here on pass (or call) by value vs pass (or
call) by reference has been particularly surreal for someone who
first encountered C when it had no longs and was working under
Edition 6 (and where its strict call by value was a real asset),
but never mind. I know it's not normative, and not going to end
any arguments, but I accidentally ran across this quote today in
an old book on C I once read almost religiously:

"One aspect of C functions may be unfamiliar to programmers who
are used to some other languages, particularly Fortran. In C, all
function arguments are passed 'by value'. This means that the
called function is given the values of its arguments in temporary
variables rather than the originals. This leads to some different
properties than are seen with 'call by reference' languages like
Fortran or with var parameters in Pascal, in which the called
routine has access to the original argument, not a local copy."
(all typos and spelling mistakes mine...).

Yes, not normative, but surely also not without some sort of
authority....
And in case anyone doesn't recognise the quote, it's from K&R2, p27. Apart from some minor punctuation differences (quoting style and a hyphen), it appears to me to be verbatim.

Yeah, it's a shame I can't find my old original K&R. [...]

K&R has text very similar to that in K&R II. Section 1.8
"Arguments - Call by Value" on page 24 begins (typos mine):

One aspect of C functions may be unfamiliar to programmers
who are used to other languages, particularly Fortran and
PL/I. In C, all function arguments are passed "by value."
This means that the called function is given the values of
its arguments in temporary variables (actually on a stack)
rather than their addresses. This leads to some different
properties than are seen with "call by reference" languages
like Fortran and PL/I, in which the called routine is handed
the address of the argument, not its value.

The changes can mostly be summarized as a backing away from detailing
the specifics of how an implementation produces the call-by-value
outcome, focusing instead on the outcome itself.

--
Eric.Sosman@xxxxxxx
.



Relevant Pages

  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... hope to see solutions in PL/I that take advantage of mixing, ... code, or Fortran code, or existing Jovial code, in a PL/I program. ... PL/I has had the ability to interface with other languages ... Whereas the Fortran object code - when executed separately ...
    (comp.lang.pl1)
  • Re: Evolution of PL/I
    ... >Much of my course deals with contemporary languages such as C++, ... >few lectures that include Fortran and COBOL, ... As has PL/I. ...
    (comp.lang.pl1)
  • Re: On Call By Value
    ... are used to some other languages, ... variables rather than the originals. ... Fortran or with var parameters in Pascal, ... like Fortran and PL/I, in which the called routine is handed ...
    (comp.lang.c)
  • Re: On Call By Value
    ... call) by reference has been particularly surreal for someone who ... are used to some other languages, ... variables rather than the originals. ... Fortran or with var parameters in Pascal, ...
    (comp.lang.c)
  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... a comparable language in the traditional areas ... You are correct that the full implementation of Fortran 2003 ... we have in mind than C++, PL/I, Ada, or Java. ... All of those languages have their good and bad points. ...
    (comp.lang.pl1)