Re: technology discussion → does the world need a "new" C ?

Liste des GroupesRevenir à l c 
Sujet : Re: technology discussion → does the world need a "new" C ?
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 10. Jul 2024, 11:12:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6lmpo$1s105$2@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
User-Agent : Mozilla Thunderbird
On 10/07/2024 02:18, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
On 10/07/2024 00:50, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
[...]
Arrays can be passed by explicit reference:
>
    void F(int(*A)[20]) {
        printf("%zu\n", sizeof(*A)/sizeof((*A)[0]));    // shows 20
    }
>
That can be called like this:
>
    int a[20];
    F(&a);
On the language level, that's passing a pointer to an array object.
The pointer itself is passed by value.  Passing a pointer to an array
is conceptually no different than passing a pointer to anything else.
>
I was replying to:
>
  "In C, arrays are not passed to functions, period."
 Which is a correct statement.
 [...]
 
But notice how C gives exactly the same result as my code that used
by-reference, even though:
>
  * C "doesn't pass arrays by reference"
  * C's F function uses the same parameter type (only & is missing; maybe
    by-ref is implicit...)
  * No explicit de-ref is needed inside F
  * No explicit address-of is needed when calling F
 Right.  The C rules that make all this possible have been explained
to you many times.  I won't waste my time explaining them to you
again.  If you were interested in learning, you would read section
6 of the comp.lang.c FAQ.
 Yes, some of C's rules make it *look like* arrays are passed by
reference.
 
So C behaves exactly as though it passes arrays by-reference, and yet
it doesn't have pass-by-reference. In fact, C does it without even
needing to be told!
 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.

and you
could get the address of an array parameter by applying unary "&" to its
name.  I know why that doesn't work.  And so do you.
The by-ref in my language has a "&" has part of the parameter type; which would be cancelled by the "&" in "&a", so it would print the value of the passed pointer - the address of the array in the caller.
The C version doesn't need that "&" in the parameter (it can't be written), so it doesn't needthe "&" in "&a". Here then you just write "a" , and that gives the address of the array in the caller.
What I'm getting at, is that there is no appreciable difference between arrays passed by-reference in my language, and arrays as they are idiomatically passed in C.
So if arrays aren't passed by value in C, and they aren't passed by reference, then how the hell ARE they passed?! Pretend you have to give a quick answer to a child; or an alien.

Date Sujet#  Auteur
9 Jul 24 * Re: technology discussion → does the world need a "new" C ?213David Brown
9 Jul 24 +* Re: technology discussion → does the world need a "new" C ?205bart
9 Jul 24 i+* Re: technology discussion → does the world need a "new" C ?202Ben Bacarisse
9 Jul 24 ii`* Re: technology discussion → does the world need a "new" C ?201bart
9 Jul 24 ii +* Re: technology discussion → does the world need a "new" C ?192Ben Bacarisse
9 Jul 24 ii i+* Re: technology discussion → does the world need a "new" C ?3BGB
10 Jul 24 ii ii`* Re: technology discussion → does the world need a "new" C ?2Ben Bacarisse
10 Jul 24 ii ii `- Re: technology discussion → does the world need a "new" C ?1BGB
9 Jul 24 ii i`* Re: technology discussion → does the world need a "new" C ?188bart
9 Jul 24 ii i +- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 ii i `* Re: technology discussion → does the world need a "new" C ?186Ben Bacarisse
10 Jul 24 ii i  `* Re: technology discussion → does the world need a "new" C ?185bart
10 Jul 24 ii i   `* Re: technology discussion → does the world need a "new" C ?184Ben Bacarisse
10 Jul 24 ii i    +- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 ii i    +* Re: technology discussion → does the world need a "new" C ?175bart
10 Jul 24 ii i    i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
10 Jul 24 ii i    i+* Re: technology discussion → does the world need a "new" C ?54Tim Rentsch
10 Jul 24 ii i    ii+* Re: technology discussion → does the world need a "new" C ?14Michael S
10 Jul 24 ii i    iii+* Re: technology discussion → does the world need a "new" C ?8David Brown
11 Jul 24 ii i    iiii`* Re: technology discussion → does the world need a "new" C ?7Michael S
11 Jul 24 ii i    iiii `* Re: technology discussion → does the world need a "new" C ?6Kaz Kylheku
11 Jul 24 ii i    iiii  `* Re: technology discussion → does the world need a "new" C ?5Michael S
11 Jul 24 ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
11 Jul 24 ii i    iiii   `- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
10 Jul 24 ii i    iii+- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 ii i    iii`* Re: technology discussion → does the world need a "new" C ?4Tim Rentsch
11 Jul 24 ii i    iii `* Re: technology discussion → does the world need a "new" C ?3BGB
11 Jul 24 ii i    iii  `* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 ii i    iii   `- Re: technology discussion → does the world need a "new" C ?1BGB
10 Jul 24 ii i    ii`* Re: technology discussion → does the world need a "new" C ?39bart
10 Jul 24 ii i    ii +* Re: technology discussion → does the world need a "new" C ?37Michael S
10 Jul 24 ii i    ii i+* Re: technology discussion → does the world need a "new" C ?34bart
11 Jul 24 ii i    ii ii+- Re: technology discussion → does the world need a "new" C ?1Michael S
11 Jul 24 ii i    ii ii`* Re: technology discussion → does the world need a "new" C ?32Tim Rentsch
11 Jul 24 ii i    ii ii `* Re: technology discussion → does the world need a "new" C ?31bart
11 Jul 24 ii i    ii ii  +* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 ii i    ii ii  i`- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 ii i    ii ii  `* Re: technology discussion → does the world need a "new" C ?28Keith Thompson
11 Jul 24 ii i    ii ii   `* Re: technology discussion → does the world need a "new" C ?27bart
11 Jul 24 ii i    ii ii    +* Re: technology discussion → does the world need a "new" C ?25Keith Thompson
11 Jul 24 ii i    ii ii    i+* Re: technology discussion → does the world need a "new" C ?15bart
12 Jul 24 ii i    ii ii    ii`* Re: technology discussion → does the world need a "new" C ?14David Brown
12 Jul 24 ii i    ii ii    ii +* Re: technology discussion → does the world need a "new" C ?12bart
12 Jul 24 ii i    ii ii    ii i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
12 Jul 24 ii i    ii ii    ii i+* Re: technology discussion → does the world need a "new" C ?7David Brown
12 Jul 24 ii i    ii ii    ii ii`* Re: technology discussion → does the world need a "new" C ?6bart
12 Jul 24 ii i    ii ii    ii ii +* Re: technology discussion → does the world need a "new" C ?2bart
13 Jul 24 ii i    ii ii    ii ii i`- Re: technology discussion → does the world need a "new" C ?1David Brown
13 Jul 24 ii i    ii ii    ii ii `* Re: technology discussion → does the world need a "new" C ?3David Brown
17 Jul 24 ii i    ii ii    ii ii  `* Re: technology discussion → does the world need a "new" C ?2Bart
17 Jul 24 ii i    ii ii    ii ii   `- Re: technology discussion → does the world need a "new" C ?1David Brown
12 Jul 24 ii i    ii ii    ii i`* Re: technology discussion → does the world need a "new" C ?3Keith Thompson
12 Jul 24 ii i    ii ii    ii i `* Re: technology discussion → does the world need a "new" C ?2James Kuyper
12 Jul 24 ii i    ii ii    ii i  `- Re: technology discussion → does the world need a "new" C ?1bart
12 Jul 24 ii i    ii ii    ii `- Re: technology discussion → does the world need a "new" C ?1BGB
11 Jul 24 ii i    ii ii    i`* Re: technology discussion → does the world need a "new" C ?9bart
11 Jul 24 ii i    ii ii    i +- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
12 Jul 24 ii i    ii ii    i +- Re: technology discussion → does the world need a "new" C ?1David Brown
12 Jul 24 ii i    ii ii    i `* Re: technology discussion → does the world need a "new" C ?6Janis Papanagnou
12 Jul 24 ii i    ii ii    i  `* Re: technology discussion → does the world need a "new" C ?5bart
13 Jul 24 ii i    ii ii    i   +* Re: technology discussion → does the world need a "new" C ?3Janis Papanagnou
13 Jul 24 ii i    ii ii    i   i`* Re: technology discussion → does the world need a "new" C ?2Keith Thompson
13 Jul 24 ii i    ii ii    i   i `- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
14 Jul 24 ii i    ii ii    i   `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
12 Jul 24 ii i    ii ii    `- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 ii i    ii i+- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
10 Jul 24 ii i    ii i`- Re: technology discussion → does the world need a "new" C ?1James Kuyper
11 Jul 24 ii i    ii `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 ii i    i+* Re: technology discussion → does the world need a "new" C ?2James Kuyper
10 Jul 24 ii i    ii`- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 ii i    i`* Re: technology discussion → does the world need a "new" C ?117Ben Bacarisse
11 Jul 24 ii i    i `* Re: technology discussion → does the world need a "new" C ?116bart
11 Jul 24 ii i    i  +* Re: technology discussion → does the world need a "new" C ?2Ben Bacarisse
11 Jul 24 ii i    i  i`- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
11 Jul 24 ii i    i  +* Re: technology discussion → does the world need a "new" C ?112Michael S
11 Jul 24 ii i    i  i`* Re: technology discussion → does the world need a "new" C ?111bart
11 Jul 24 ii i    i  i +- Re: technology discussion → does the world need a "new" C ?1Michael S
11 Jul 24 ii i    i  i `* Re: technology discussion → does the world need a "new" C ?109David Brown
11 Jul 24 ii i    i  i  `* Re: technology discussion → does the world need a "new" C ?108bart
11 Jul 24 ii i    i  i   `* Re: technology discussion → does the world need a "new" C ?107David Brown
11 Jul 24 ii i    i  i    `* Re: technology discussion → does the world need a "new" C ?106bart
11 Jul 24 ii i    i  i     +- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
12 Jul 24 ii i    i  i     +* Re: technology discussion → does the world need a "new" C ?103David Brown
12 Jul 24 ii i    i  i     i`* Re: technology discussion → does the world need a "new" C ?102Janis Papanagnou
12 Jul 24 ii i    i  i     i +* Re: technology discussion → does the world need a "new" C ?29bart
12 Jul 24 ii i    i  i     i i+* Re: technology discussion → does the world need a "new" C ?23Kaz Kylheku
12 Jul 24 ii i    i  i     i ii`* Re: technology discussion → does the world need a "new" C ?22Keith Thompson
25 Aug 24 ii i    i  i     i ii +- Re: technology discussion ? does the world need a "new" C ?1dave thompson 2
2 Sep 24 ii i    i  i     i ii `* Re: technology discussion → does the world need a "new" C ?20Tim Rentsch
2 Sep 24 ii i    i  i     i ii  `* Re: technology discussion → does the world need a "new" C ?19Keith Thompson
2 Sep 24 ii i    i  i     i ii   `* Re: technology discussion → does the world need a "new" C ?18Ben Bacarisse
2 Sep 24 ii i    i  i     i ii    +* Re: technology discussion → does the world need a "new" C ?2Keith Thompson
8 Sep 24 ii i    i  i     i ii    i`- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
16 Sep 24 ii i    i  i     i ii    `* Re: technology discussion → does the world need a "new" C ?15Tim Rentsch
16 Sep 24 ii i    i  i     i ii     +* Re: technology discussion → does the world need a "new" C ?13Keith Thompson
16 Sep 24 ii i    i  i     i ii     i+* Re: technology discussion → does the world need a "new" C ?4Janis Papanagnou
17 Sep 24 ii i    i  i     i ii     ii`* Re: technology discussion → does the world need a "new" C ?3Tim Rentsch
17 Sep 24 ii i    i  i     i ii     ii `* Re: technology discussion → does the world need a "new" C ?2Janis Papanagnou
17 Sep 24 ii i    i  i     i ii     ii  `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
26 Sep 24 ii i    i  i     i ii     i`* Re: technology discussion → does the world need a "new" C ?8Tim Rentsch
16 Sep 24 ii i    i  i     i ii     `- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
12 Jul 24 ii i    i  i     i i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
12 Jul 24 ii i    i  i     i i`* Re: technology discussion → does the world need a "new" C ?4Keith Thompson
12 Jul 24 ii i    i  i     i +* Re: technology discussion → does the world need a "new" C ?2Kaz Kylheku
12 Jul 24 ii i    i  i     i `* Re: technology discussion → does the world need a "new" C ?70Michael S
12 Jul 24 ii i    i  i     `- Re: technology discussion → does the world need a "new" C ?1James Kuyper
11 Jul 24 ii i    i  `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 ii i    `* Re: technology discussion → does the world need a "new" C ?7Janis Papanagnou
9 Jul 24 ii `* Re: technology discussion → does the world need a "new" C ?8Kaz Kylheku
9 Jul 24 i+- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i`- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
9 Jul 24 +- Re: technology discussion → does the world need a "new" C ?1Michael S
9 Jul 24 `* Re: technology discussion → does the world need a "new" C ?6BGB

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal