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 : 12. Jul 2024, 21:38:24
Autres entêtes
Organisation : None to speak of
Message-ID : <87o772s5vj.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 12/07/2024 16:58, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
[...]
If you had to describe to someone how a function accesses array data
in its caller, what would you say?
The same thing I've written to you many times over the last several
years in this newsgroup.
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.
Yes, function can access array data by means other than passing
arrays
as parameters.
Or would you merely refer to the relevant section in the language reference?
That, and to section 6 of the comp.lang.c FAQ, which is an excellent
description of C's treatment of arrays and pointers. You've repeatedly
declined to say whether you've read it. I encourage you to do so.
Just curious.
Sure you are.
>
Actually, I /was/ genuinely curious as to how a function's access to
its caller's array elements are described without using 'pointer' or
'reference'.
So now you're restricting the words that can be used in the explanation.
You didn't mention that restriction before. You're moving the
goalposts.
Any accurate explanation of how a function accesses elements of what
looks like an array parameter depends on pointers. I believe you
understand that perfectly well, but if you want to ask about some
specific code I might consider explaining it yet again.
"Reference" is an informal term that describes what pointers are. The
problem is that it's also a formal term that refers to features that C
doesn't have (C++-style references and function arguments passed by
reference).
Because as AFAIK this whole subthread seems to about people trying to
catch me out on some pedantry.
>
All it needed was for someone to agree that yes, arrays are
/effectively/ passed by reference, even if it's not true by-reference
and not a general purpose feature of the language.
If I'm not mistaken, I don't believe you've ever acknowledged
the underlying mechanism of how arrays are "passed" to functions.
Will you do so now?
Given:
void func(int param[10]) {
... param[5] ...
}
...
int argument[10] = ...;
func(argument);
can *you* explain the semantics in terms consistent with the way
the C standard describes them? (This is of course an incomplete
code fragment. I can provide a complete program if you think
it's necessary.)
[...]
Your acknowledgement that you've read section 6 of the comp.lang.c
FAQ is a prerequisite to any further substantive response from me.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */