Deutsch   English   Français   Italiano  
<87mskqtip3.fsf@bsb.me.uk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ben Bacarisse <ben@bsb.me.uk>
Newsgroups: comp.lang.c
Subject: Re: technology discussion =?utf-8?Q?=E2=86=92?= does the world need
 a "new" C ?
Date: Mon, 02 Sep 2024 12:10:16 +0100
Organization: A noiseless patient Spider
Lines: 105
Message-ID: <87mskqtip3.fsf@bsb.me.uk>
References: <v66eci$2qeee$1@dont-email.me> <v6k6i0$1h4d3$1@dont-email.me>
	<87ed82p28y.fsf@bsb.me.uk> <v6m03l$1tf05$1@dont-email.me>
	<87r0c1nzjj.fsf@bsb.me.uk> <v6m716$1urj4$1@dont-email.me>
	<87ikxconq4.fsf@bsb.me.uk> <v6n8iu$24af0$1@dont-email.me>
	<20240711115418.00001cdf@yahoo.com> <v6oamt$2d8nn$1@dont-email.me>
	<v6oct4$2djgq$2@dont-email.me> <v6of96$2ekb0$1@dont-email.me>
	<v6ovfc$2hcpf$1@dont-email.me> <v6p4hf$2icph$1@dont-email.me>
	<v6qgpu$2t6p7$3@dont-email.me> <v6r33m$30grj$1@dont-email.me>
	<v6r3iv$30gru$1@dont-email.me> <20240712045301.394@kylheku.com>
	<87sewesg89.fsf@nosuchdomain.example.com> <865xresvxz.fsf@linuxsc.com>
	<87h6ay3jaz.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 02 Sep 2024 13:10:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b4d916073543bb26ad927b304ce4cba0";
	logging-data="2228665"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18ePZ8Th92OrmMC7PSnEvLyyhWT1//HIQs="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:RcvRyIBCpDr6Pkv01zXDJ9p+rBg=
	sha1:3Sr//izZffOLlVB8/ESKFxTXFlE=
X-BSB-Auth: 1.5c50a0c6140f98f073ed.20240902121016BST.87mskqtip3.fsf@bsb.me.uk
Bytes: 6715

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Kaz Kylheku <643-408-1753@kylheku.com> writes:
>>>> On 2024-07-12, bart <bc@freeuk.com> wrote:
>>>>> It's clearly not by value.  It's apparently not by reference.  You
>>>>> can't get away with saying they are not passed, as clearly
>>>>> functions *can* access array data via parameters.
>>>>
>>>> Actually, you probably can get away with saying that it is "passed
>>>> by reference".
>>>>
>>>> The formal term that doesn't apply is "call by reference";  that's
>>>> what C doesn't have.
>>>>
>>>> "call by reference" emphasizes that the function call mechanism
>>>> provides the reference semantics for a formal parameter, not that
>>>> some arbitrary means of passage of the data has reference
>>>> semantics.
>>>
>>> [...]
>>>
>>> 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 in others (C++, Pascal, Ada) you can
>>> select by-value or by-reference for each parameter.  "Pass by
>>> (reference|value)" feels more precise.
>>>
>>> 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.
>>
>> I suspect that your guess here is influenced more by what you would
>> like to be true than what is likely to be true.
>
> I was influenced by what I thought made the most sense.
>
>> What is likely to be true is that these terms entered the language
>> at essentially the same time as the original Algol.  Algol 60 has
>> both call by name and call by value, referred to by those names in
>> the Algol 60 Report, and selectable on a per-parameter basis.
>>
>> By contrast the precursor to Algol 60, the International Algebraic
>> Language or IAL for short (and referred to after the fact as Algol
>> 58) did not use either term, and described the coupling between
>> arguments and parameters only in somewhat vague English prose that
>> left unclear exactly what the binding mechanism(s) were to be.
>> (There was a description for functions and a separate description
>> for procedures, not quite the same, and both not completely clear
>> exactly what the mechanism was meant to be.)
>>
>> Thus it seems likely that the terms call by name, call by value,
>> and perhaps other similar terms, first arose during the discussions
>> of the Algol 60 working group in the late 1950s, and entered the
>> general lexicon with or perhaps slightly before the publication of
>> the Algol 60 Report, which describes and allows both call by name
>> and call by value, selectable on a per-parameter base, and referred
>> to by those names in the published Algol 60 Report.
>
> Yes, that does seem likely.
>
> I'm mildly disappointed.  Since arguments are *passed* and
> functions/procedures are *called*, surely it would have made more sense
> to use "pass by value" rather than "call by value", especially in a
> language where the mechanism can vary per parameter.

All that is, I think, due to subsequent changes in (English) language
use.  In Algol 60, procedures were invoked and /parameters/ were called
by value or name.  Maybe the term was intended to reflect the idea that
the code in the body "called for the value" of the parameter.

The word "call" now refers, almost universally, to invoking a function
or procedure.  As a result, the idea of "calling a parameter" reads
oddly, but at the time I'm sure it seemed perfectly reasonable.

There is a nice historical irony here.  Call by name would often have to
be implemented as something akin to passing a "thunk" (a parameterless
lambda) so the parameter would indeed be "called" (in the modern sense)
when the value as "called for" (in the Algol sense) in the procedure.

> (Yes, this is my opinion.)
>
> If there's some reason why "call by value" actually made more sense than
> "pass by value", I'm not aware of it.
>
> Since the phrase "pass by value" is now in common use, I'll continue to
> use that term in preference to "call by value" (likewise "by
> reference").

I use those terms too.  It would be confusing these days to talk about
calling a parameter, and the phrase "call by value" suggests (as it
never did at the time) something so do with the function calling
mechanism in general.  This is compounded by the fact that modern
programming languages has almost universally settled on calling all
parameters by value (to the use the old phrase) so, usually, the terms
can, in fact, be used to talk about the function calling mechanism.

-- 
Ben.