Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: technology discussion =?utf-8?Q?=E2=86=92?= does the world need a "new" C ?
Date: Tue, 09 Jul 2024 14:23:47 -0700
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <86v81e8djw.fsf@linuxsc.com>
References: <871q48w98e.fsf@nosuchdomain.example.com> <87wmlzvfqp.fsf@nosuchdomain.example.com> <87h6d2uox5.fsf@nosuchdomain.example.com> <20240707164747.258@kylheku.com> <877cdur1z9.fsf@bsb.me.uk> <871q42qy33.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 09 Jul 2024 23:23:48 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4404f50b61bba69374b6468dfb9554fc"; logging-data="1623985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1875uu2D/zlg5eSJO1jC1tFfYPbg85dY08="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:N25XN7+lCa9EdgO8Ya0fF44ljwA= sha1:xZYlOBnuKT0nOe/rzK+LLQdZvc8=
Xref: csiph.com comp.lang.c:386962
bart writes:
> On 09/07/2024 18:22, Ben Bacarisse wrote:
>
>> bart writes:
>>
>>> On 09/07/2024 16:58, Ben Bacarisse wrote:
>>>
>>>> bart writes:
>>>>
>>>>> Arrays are passed by reference:
>>>>>
>>>>> void F(int a[20]) {}
>>>>>
>>>>> int main(void) {
>>>>> int x[20];
>>>>> F(x);
>>>>> }
>>>>
>>>> This is the sort of thing that bad tutors say to students so that they
>>>> never learn C properly. All parameter passing in C is by value. All of
>>>> it. You just have to know (a) what the syntax means and (b) what values
>>>> get passed.
>>>
>>> The end result is that a parameter declared with value-array syntax is
>>> passed using a reference rather than by value.
>>>
>>> And it does so because the language says, not because the ABI requires
>>> it. A 2-byte array is also passed by reference.
>>
>> An address value is passed by value. C has only one parameter passing
>> mechanism. You can spin it as much as you like, but C's parameter
>> passing is simple to understand, provided learner tune out voices like
>> yours.
>
> Little about C's type system is simple. You're doing your students a
> disservice if you try and hide all the quirks.
That's what you are doing, only worse.