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

Liste des GroupesRevenir à cl c 
Sujet : Re: technology discussion → does the world need a "new" C ?
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 09. Jul 2024, 16:31:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6jhk3$1drd6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 08/07/2024 19:39, BGB wrote:
On 7/7/2024 11:28 PM, James Kuyper wrote:
On 7/7/24 20:02, Kaz Kylheku wrote:
...

 
I see no point in having implicit pointers, but I don't believe that
they are prohibited.
>
 They mostly exist in a "sort of simpler to implement the compiler this way" sense.
 In the implicit pointer case, the compiler just treats it as-if it were an explicit pointer. In this case, both are basically treated as being roughly equivalent at the IR levels.
 And, most of the code-generation stage doesn't need separate handling for arrays and pointers, but can use combined "ArrayOrPointer" handling or similar.
 It had all seemed "obvious enough".
    Similar reasoning for passing structs by-reference in the ABI:
   Pass by reference is easy to implement;
   In place copying and decomposing into registers, kinda bad.
 Though, this one seems to be a common point of divergence between "SysV" and "Microsoft" ABIs. Sometimes a target will have an ABI defined, and the MS version was almost the same, just typically differing in that it passes structs by reference and provides a spill space for register arguments.
 
I don't think it is helpful that you keep mixing /logical/ terms with /implementation/ terms.
In C, there is no "pass by reference" or "return by reference".  It is all done by value.  Even when you use pointer arguments or return types, you are passing or returning pointer values.  C programmers use pointers to get the effect of passing by reference, but in C you use pointers to be explicit about references.
Structs in C are passed by value, and returned by value.  Not by reference.
The C standards don't say how passing structs around by value is to be implemented - that is hidden from the programmer.  Usually ABI's (which are also hidden from the programmer) specify the implementation details, but some ABI's are weak in that area.  Generally, structs up to a certain size or complexity are passed in registers while bigger or more advanced types are passed via addresses (pointing to stack areas) in registers or the stack, just like any other bigger types.  This is not "pass by reference" as far as the C programming is concerned - but you could well call it that at the assembly level.  Where the line between "passing in registers" and "passing via addresses to space on the stack" is drawn, is entirely up to the compiler implementation and any ABI requirements.  Some simpler compilers will pass all structs via addresses, no matter how simple they are, while others will aim to use registers whenever possible.
So if you have these structs and declarations :
struct small { uint16_t a; uint16_t b; };
struct big { uint32_t xs[10]; };
struct small foos(struct small y);
struct big foob(struct big y);
Then compilers will typically implement "x = foos(y)" as though it were:
extern uint32_t foos(uint32_t ab);
uint32_t _1 = foos(y.a << 16) | (y.b);
struct small x = { _1 >> 16, _1 & 0xffff };
And they will typically implement "x = foosb(y)" as though it were:
extern void foob(struct big * ret, const struct big * xs);
struct big x;
foob(&x, &y);
This is not, as you wrote somewhere, something peculiar to MSVC - it is the technique used by virtually every C compiler, except perhaps for outdated brain-dead 8-bit microcontrollers that have difficulty handling data on a stack.
And it is not really "pass by reference" or "implicit pointers", it is just passing addresses around behind the scenes in the implementation.

Date Sujet#  Auteur
4 Jul 24 * technology discussion → does the world need a "new" C ?301aotto1968
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?298Lawrence D'Oliveiro
5 Jul 24 i`* Re: technology discussion → does the world need a "new" C ?297BGB
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?2Lawrence D'Oliveiro
5 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1yeti
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?267Keith Thompson
5 Jul 24 i i+- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i i+* Re: technology discussion → does the world need a "new" C ?264BGB
5 Jul 24 i ii+* Re: technology discussion → does the world need a "new" C ?18Ben Bacarisse
5 Jul 24 i iii`* Re: technology discussion → does the world need a "new" C ?17BGB
6 Jul 24 i iii +* Re: technology discussion → does the world need a "new" C ?14Ben Bacarisse
6 Jul 24 i iii i+* Re: technology discussion → does the world need a "new" C ?9BGB
6 Jul 24 i iii ii+* Re: technology discussion → does the world need a "new" C ?2David Brown
6 Jul 24 i iii iii`- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i iii ii`* Re: technology discussion → does the world need a "new" C ?6Ben Bacarisse
7 Jul 24 i iii ii +* Re: technology discussion → does the world need a "new" C ?2Keith Thompson
7 Jul 24 i iii ii i`- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
7 Jul 24 i iii ii `* Re: technology discussion → does the world need a "new" C ?3BGB
7 Jul 24 i iii ii  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii i`* Re: technology discussion → does the world need a "new" C ?4Malcolm McLean
6 Jul 24 i iii i `* Re: technology discussion → does the world need a "new" C ?3BGB
6 Jul 24 i iii i  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii i   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii `* Re: technology discussion → does the world need a "new" C ?2Janis Papanagnou
6 Jul 24 i iii  `- Re: technology discussion → does the world need a "new" C ?1BGB
5 Jul 24 i ii`* Re: technology discussion → does the world need a "new" C ?245Keith Thompson
6 Jul 24 i ii `* Re: technology discussion → does the world need a "new" C ?244Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?228BGB
6 Jul 24 i ii  i+- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i ii  i+* Re: technology discussion → does the world need a "new" C ?6James Kuyper
6 Jul 24 i ii  ii`* Re: technology discussion → does the world need a "new" C ?5BGB
9 Jul 24 i ii  ii `* Re: technology discussion → does the world need a "new" C ?4David Brown
9 Jul 24 i ii  ii  `* Re: technology discussion → does the world need a "new" C ?3Michael S
9 Jul 24 i ii  ii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i ii  i`* Re: technology discussion → does the world need a "new" C ?220Keith Thompson
7 Jul 24 i ii  i +* Re: technology discussion → does the world need a "new" C ?215BGB
7 Jul 24 i ii  i i`* Re: technology discussion → does the world need a "new" C ?214James Kuyper
7 Jul 24 i ii  i i `* Re: technology discussion → does the world need a "new" C ?213BGB
8 Jul 24 i ii  i i  `* Re: technology discussion → does the world need a "new" C ?212James Kuyper
8 Jul 24 i ii  i i   `* Re: technology discussion → does the world need a "new" C ?211Kaz Kylheku
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1BGB
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
8 Jul 24 i ii  i i    +* Re: technology discussion → does the world need a "new" C ?207James Kuyper
8 Jul 24 i ii  i i    i`* Re: technology discussion → does the world need a "new" C ?206BGB
9 Jul 24 i ii  i i    i `* Re: technology discussion → does the world need a "new" C ?205David Brown
9 Jul 24 i ii  i i    i  +* Re: technology discussion → does the world need a "new" C ?197bart
9 Jul 24 i ii  i i    i  i+* Re: technology discussion → does the world need a "new" C ?194Ben Bacarisse
9 Jul 24 i ii  i i    i  ii`* Re: technology discussion → does the world need a "new" C ?193bart
9 Jul 24 i ii  i i    i  ii +* Re: technology discussion → does the world need a "new" C ?184Ben Bacarisse
9 Jul 24 i ii  i i    i  ii i+* Re: technology discussion → does the world need a "new" C ?3BGB
10 Jul 24 i ii  i i    i  ii ii`* Re: technology discussion → does the world need a "new" C ?2Ben Bacarisse
10 Jul 24 i ii  i i    i  ii ii `- Re: technology discussion → does the world need a "new" C ?1BGB
9 Jul 24 i ii  i i    i  ii i`* Re: technology discussion → does the world need a "new" C ?180bart
9 Jul 24 i ii  i i    i  ii i +- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i `* Re: technology discussion → does the world need a "new" C ?178Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i  `* Re: technology discussion → does the world need a "new" C ?177bart
10 Jul 24 i ii  i i    i  ii i   `* Re: technology discussion → does the world need a "new" C ?176Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    +- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    +* Re: technology discussion → does the world need a "new" C ?167bart
10 Jul 24 i ii  i i    i  ii i    i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?54Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    ii+* Re: technology discussion → does the world need a "new" C ?14Michael S
10 Jul 24 i ii  i i    i  ii i    iii+* Re: technology discussion → does the world need a "new" C ?8David Brown
11 Jul 24 i ii  i i    i  ii i    iiii`* Re: technology discussion → does the world need a "new" C ?7Michael S
11 Jul 24 i ii  i i    i  ii i    iiii `* Re: technology discussion → does the world need a "new" C ?6Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii  `* Re: technology discussion → does the world need a "new" C ?5Michael S
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
11 Jul 24 i ii  i i    i  ii i    iiii   `- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
11 Jul 24 i ii  i i    i  ii i    iii+- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iii`* Re: technology discussion → does the world need a "new" C ?4Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii `* Re: technology discussion → does the world need a "new" C ?3BGB
11 Jul 24 i ii  i i    i  ii i    iii  `* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii   `- Re: technology discussion → does the world need a "new" C ?1BGB
10 Jul 24 i ii  i i    i  ii i    ii`* Re: technology discussion → does the world need a "new" C ?39bart
10 Jul 24 i ii  i i    i  ii i    ii +* Re: technology discussion → does the world need a "new" C ?37Michael S
10 Jul 24 i ii  i i    i  ii i    ii i+* Re: technology discussion → does the world need a "new" C ?34bart
11 Jul 24 i ii  i i    i  ii i    ii ii+- Re: technology discussion → does the world need a "new" C ?1Michael S
11 Jul 24 i ii  i i    i  ii i    ii ii`* Re: technology discussion → does the world need a "new" C ?32Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii `* Re: technology discussion → does the world need a "new" C ?31bart
11 Jul 24 i ii  i i    i  ii i    ii ii  +* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii  i`- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    ii ii  `* Re: technology discussion → does the world need a "new" C ?28Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii   `* Re: technology discussion → does the world need a "new" C ?27bart
11 Jul 24 i ii  i i    i  ii i    ii ii    +* Re: technology discussion → does the world need a "new" C ?25Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii    i+* Re: technology discussion → does the world need a "new" C ?15bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii`* Re: technology discussion → does the world need a "new" C ?14David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii +* Re: technology discussion → does the world need a "new" C ?12bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+* Re: technology discussion → does the world need a "new" C ?7David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii`* Re: technology discussion → does the world need a "new" C ?6bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii +* Re: technology discussion → does the world need a "new" C ?2bart
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii i`- Re: technology discussion → does the world need a "new" C ?1David Brown
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii `* Re: technology discussion → does the world need a "new" C ?3David Brown
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii  `* Re: technology discussion → does the world need a "new" C ?2Bart
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii   `- Re: technology discussion → does the world need a "new" C ?1David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i`* Re: technology discussion → does the world need a "new" C ?3Keith Thompson
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i `* Re: technology discussion → does the world need a "new" C ?2James Kuyper
12 Jul 24 i ii  i i    i  ii i    ii ii    ii `- Re: technology discussion → does the world need a "new" C ?1BGB
11 Jul 24 i ii  i i    i  ii i    ii ii    i`* Re: technology discussion → does the world need a "new" C ?9bart
12 Jul 24 i ii  i i    i  ii i    ii ii    `- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    ii i+- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii i`- Re: technology discussion → does the world need a "new" C ?1James Kuyper
11 Jul 24 i ii  i i    i  ii i    ii `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?2James Kuyper
11 Jul 24 i ii  i i    i  ii i    i`* Re: technology discussion → does the world need a "new" C ?109Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    `* Re: technology discussion → does the world need a "new" C ?7Janis Papanagnou
10 Jul 24 i ii  i i    i  ii `* Re: technology discussion → does the world need a "new" C ?8Kaz Kylheku
9 Jul 24 i ii  i i    i  i+- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  i i    i  i`- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
9 Jul 24 i ii  i i    i  +- Re: technology discussion → does the world need a "new" C ?1Michael S
9 Jul 24 i ii  i i    i  `* Re: technology discussion → does the world need a "new" C ?6BGB
9 Jul 24 i ii  i i    `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i `* Re: technology discussion → does the world need a "new" C ?4Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?9James Kuyper
7 Jul 24 i ii  `* Re: technology discussion → does the world need a "new" C ?6Keith Thompson
6 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?26bart
5 Jul 24 i `- Re: technology discussion → does the world need a "new" C ?1lexi hale
7 Jul 24 `* Re: technology discussion → does the world need a "new" C ?2Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal