Sujet : Re: technology discussion → does the world need a "new" C ?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 12. Jul 2024, 14:22:29
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6ramn$31q88$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 12.07.2024 13:21, bart wrote:
On 12/07/2024 12:12, Janis Papanagnou wrote:
On 12.07.2024 08:00, David Brown wrote:
[...]
>
I can understand when someone new to C gets mixed up about how arrays
work.
>
I can't understand that if I presume that the person has read any
basic textbook about "C".
>
I don't understand how someone can remain so stubbornly confused
when they have been told how C /actually/ works.
>
Especially if the one has said to have written an own language that
is close enough to "C" where I'd expect the knowledge to be there
already before that person is designing and implementing his project.
>
I wonder why he refuses to look up things if he thinks that all the
experts here are wrong about a well documented fact.
If you had to describe to someone how a function accesses array data in
its caller, what would you say?
I would explain it as it is, in a way similar to what was already
written in this thread. (It had been formulated repeatedly and I
will not repeat it again.)
Someone here (don't recall who it was) already had provided a good
post about how difficult it gets if you build your argument around
an inappropriate model.
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.
To explain it to newbies I'd abstain from using parameter-passing
terms at all; and especially in "C" that's simple because you have
just one mechanism, so you don't need to mention it to distinguish
it from any other mechanisms [that exist in other languages].
I'd just explain what happens if you write f(int a[]) and - since
the pointers are so basic a concept in "C" - I'd likely explain it
in terms of f(int * p) .
Or would you merely refer to the relevant section in the language
reference?
If you mean the standards' documents; no. I don't think that such
documents are good for learning or explaining a language. But they
help to get formal certainty about facts; useful for experts like
the ones here in this group (and certainly not excluding you).
Just curious.
Fair enough.
Janis