Sujet : Re: technology discussion → does the world need a "new" C ?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 10. Jul 2024, 21:05:15
Autres entêtes
Organisation : None to speak of
Message-ID : <8734ohvwqs.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
On 10/07/2024 02:18, Keith Thompson wrote:
[...]
If you actually believed that C has pass-by-reference for arrays, it
would indicate that you don't understand C. But you're only pretending
to believe it.
If C had pass-by-reference for arrays, then presumably you could
obtain the size of an array parameter by applying sizeof to its name,
>
That's what my example did. But only if the array has a specific bound
in the parameter type, not if it's unbounded, since (1) a function can
be passed arrays of different sizes; (2) C arrays don't normally
contain their length.
No, that's not what your example did. Your example was:
void F(int(*A)[20])
You defined A explicitly as a pointer.
I believe you understand what I actually meant by "If C had
pass-by-reference for arrays, then presumably you could obtain the size
of an array parameter by applying sizeof to its name". If you tell me
that you don't honestly don't understand it and that you really beleve
that your example is the same thing, I'll explain it yet again.
[...]
So if arrays aren't passed by value in C, and they aren't passed by
reference, then how the hell ARE they passed?!
They aren't. C doesn't have array parameters. You can emulate array
parameters using pointers. The emulation is not perfect.
Pretend you have to
give a quick answer to a child; or an alien.
No.
bart, have you read section 6 of the comp.lang.c FAQ?
Yes or no, please.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */