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 <v9ktep$v5sk$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v9ktep$v5sk$1@dont-email.me>

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

Path: ...!news.nobody.at!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: Thu, 15 Aug 2024 13:48:25 +0100
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <v9ktep$v5sk$1@dont-email.me>
References: <v66eci$2qeee$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> <20240712154252.00005c2f@yahoo.com>
 <86o7717jj1.fsf@linuxsc.com> <v6ti10$3gru4$1@dont-email.me>
 <v78af7$1qkuf$1@dont-email.me> <20240717163457.000067bb@yahoo.com>
 <v78piu$1su4u$1@dont-email.me> <86a5hep45h.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 15 Aug 2024 14:48:26 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fcb44464f1714e8680386692a2a2f20c";
	logging-data="1021844"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/7C47G+tZQMqe3kRWxYQj3"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pb1yhkrtvrINkdJanZz0fxCLqoA=
In-Reply-To: <86a5hep45h.fsf@linuxsc.com>
Content-Language: en-GB
Bytes: 4483


On 15/08/2024 09:43, Tim Rentsch wrote:
 > Bart <bc@freeuk.com> writes:
 >
 > [on comparing array arguments in C with call-by-reference]
 >
 >> [...] the differences [between C rules and true call-by-reference]
 >> can be summarised here;  [...]
 >>
 >>                                   Call     Array access in callee
 >>
 >>      C call-by-value              F(A)     A[i]
 >>
 >>      true call-by-reference       H(A)     A[i]
 >>
 >> What the user has to write is what's important, and here it is clear
 >> that they write the same thing [in the two cases shown].
 >
 >
 > The comparison above is misleading because it is incomplete.
 > Let's compare the two modes more fully:
 >
 >
 >                          C call-by-value         call-by-reference
 >                          ===============         =================
 >    at call:
 >
 >      (array argument)    F(A)                    H(A)
 >
 >      (pointer argument)  F(p)                    (disallowed)

My posts were about passing *arrays* and the fact that C's pass-by-value 
was remarkably similar to pass-by-reference.

However your entry for pointers is not correct: you can pass pointers by 
reference (in C, it means passing a T** type instead of T* to emulate that).

 >
 >      (null argument)     F(0)                    (disallowed)

Pass-by-reference necessarily requires an lvalue at the call-site since 
it effectively applies & to the argument.

 >
 >    inside function:
 >
 >      (access)            A[i]                    A[i]
 >
 >      (update)            A[i] = ...              A[i] = ...
 >
 >      sizeof A            (pointer size)          (array size)

That's one of the small differences. But you only get the array size in 
a language where the array type includes its length. Otherwise, you only 
get it if it's part of the parameter type.

 >      A++                 (changes A variable)    (disallowed)

(In my language ++A is allowed. I'm not sure why, it's likely a bug.)

 >      A = (new value)     (changes A variable)    (disallowed)

This is allowed too in my language, if the array has a fixed size. It 
reassigns the whole array.

In C you can't do A = B for other reasons, since arrays aren't 
manipulated by value. But you can do this:

     memcpy(A, B, n);

and it will overwrite caller's array with B. That other language can 
also choose to call memcpy().


 > The more complete comparion illustrate why C semantics should not
 > be thought of as call-by-reference.

It was made clear more than once that it wasn't exact call-by-reference.

It was also made clear that there were enough similarities that adding 
real call-by-reference arrays to C would buy you very little.