Sujet : Re: technology discussion ? does the world need a "new" C ?
De : dave_thompson_2 (at) *nospam* comcast.net
Groupes : comp.lang.cDate : 25. Aug 2024, 22:16:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <2i7ncj9n2h0kfrfd610jght8k692mdmv04@4ax.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Forte Agent 3.3/32.846
On Fri, 12 Jul 2024 09:54:46 -0700, Keith Thompson
<Keith.S.Thompson+
u@gmail.com> wrote:
[snip]
I know that "call by reference" is the usual formal term, but I
personally prefer "pass by reference".
The terms "call by reference" and "call by value" emphasize the call,
implying that all arguments in a given call are passed with the same
mechanism. In some languages that's true (C argument passing is purely
by value, and Fortran, as I understand it, is purely by reference), but
Nope. Since 1990 Fortran supports several options for argument passing
-- optionally including some that provide interoperability with (at
least one implementation of) C! -- but even taking 'classic' FORTRAN
either reference or copyin-copyout was allowed, and important
compilers (like IBM) were known to use both. Until c.l.f recently
lapsed into desuetude, this was a FAQ -- "this dusty-deck code doesn't
work as I expected on the basis that FORTRAN used to be by-ref" ->
"you expected wrong".
OTOH COBOL did make everything by-reference, at least up to 1985. And
I believe PL/I, but I didn't get deeply into that.
FORTH, like C, was always by-value where the value could be an address
-- with no target type information (like C void*).
in others (C++, Pascal, Ada) you can select by-value or by-reference for
each parameter. "Pass by (reference|value)" feels more precise.
C++ and Pascal -- and algol68 -- yes. Ada no, or not standardly; it
specifies a few types that must be by-value and a few more that must
be by-reference (mostly ones that can't be copied safely, or at all),
and for everything else lets the compiler choose. I'm unsure if the
standard allows extension(s) about this, but even if so I doubt it
would be popular with Ada users (demotivating implementors).
I haven't checked, but I suspect the terms "call by (reference|value)"
predate languages that allowed the mechanism to be specified for each
parameter.
Definitely.