Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v6m03l$1tf05$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v6m03l$1tf05$1@dont-email.me>

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

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: =?UTF-8?Q?Re=3A_technology_discussion_=E2=86=92_does_the_world_need?=
 =?UTF-8?B?IGEgIm5ldyIgQyA/?=
Date: Wed, 10 Jul 2024 13:51:02 +0100
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <v6m03l$1tf05$1@dont-email.me>
References: <v66eci$2qeee$1@dont-email.me> <v687h2$36i6p$1@dont-email.me>
 <871q48w98e.fsf@nosuchdomain.example.com> <v68dsm$37sg2$1@dont-email.me>
 <87wmlzvfqp.fsf@nosuchdomain.example.com> <v6ard1$3ngh6$4@dont-email.me>
 <v6b0jv$3nnt6$1@dont-email.me> <87h6d2uox5.fsf@nosuchdomain.example.com>
 <v6d779$6rk5$2@dont-email.me> <v6e76u$c0i9$1@dont-email.me>
 <v6esqm$fian$2@dont-email.me> <v6f7vg$hgam$1@dont-email.me>
 <20240707164747.258@kylheku.com> <v6gl83$s72a$1@dont-email.me>
 <v6h8ao$ur1v$1@dont-email.me> <v6jhk3$1drd6$1@dont-email.me>
 <v6jiud$1dsjb$1@dont-email.me> <877cdur1z9.fsf@bsb.me.uk>
 <v6joi4$1epoj$1@dont-email.me> <871q42qy33.fsf@bsb.me.uk>
 <v6k6i0$1h4d3$1@dont-email.me> <87ed82p28y.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 10 Jul 2024 14:51:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ded9e1848a26cfa2c70264cde0490f0f";
	logging-data="2014213"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Y2X3/R+G+emJfihLQ/yEE"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:2FoGDtuDZBJwsal3TfqzZRpvXTo=
In-Reply-To: <87ed82p28y.fsf@bsb.me.uk>
Content-Language: en-GB
Bytes: 4921

On 10/07/2024 00:35, Ben Bacarisse wrote:
> bart <bc@freeuk.com> writes:
> 
>> On 09/07/2024 18:22, Ben Bacarisse wrote:
>>> bart <bc@freeuk.com> writes:
>>>
>>>> On 09/07/2024 16:58, Ben Bacarisse wrote:
>>>>> bart <bc@freeuk.com> 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.
> 
> Parameter passing is relatively simple though since there is only one
> mechanism -- pass by value.

Except when it comes to arrays. Obviously arrays aren't passed by value, 
but that's because of X and Y.

What would be genuinely simple is:

    void F(T x) {}
    void G(T* y) {}

where an object of type T is always passed by value, and that of type T* 
always passes a pointer to the value. Here, T represents exactly the 
same type as when it used outside a parameter list:

    T a;
    T* p;

but only in the context of C is it necessary to mention that, since it 
C, that may not be the case.

(The mechanisms of the underlying ABI do not affect this; they just make 
implementation harder.)

>> You're doing your students a
>> disservice if you try and hide all the quirks.
> 
> If.  Always with the if.  There are lots of things I don't do that would
> be doing my students a disservice were I to do them.  Beautiful spin!


Have a look at forums like the Reddit one on C programming, to see the 
kinds of things that people learning C get confused about. Lots of them 
are to do with the funny quirks of C, and a big proportion are due to 
how arrays and pointers are so intertwined in that language.

Well, C can't be fixed. But what would you do: explain the flaws in the 
language, the discontinuities, or brush them under the carpet?

Or maybe explain the quirks, but pretend they are by design?

What I find especially wonderful is that every time you see a pointer 
type like T*, C gives you an extra array dimension on top, whether or 
not T actually points to the first element of an array.

So you never know whether T* is intended to represent a 0- or 
1-dimensioned object, or a 1- or 2-dimensioned one.

And what I find frustrating is that people learning C get the idea that 
all this quirkiness goes hand-in-hand with lower-level programming.