Sujet : Re: "A diagram of C23 basic types"
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 10. Apr 2025, 12:08:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vt88sa$2rv8r$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 23
User-Agent : Mozilla Thunderbird
On 10/04/2025 11:07,
Muttley@DastardlyHQ.org wrote:
On Thu, 10 Apr 2025 09:53:40 +0200
David Brown <david.brown@hesbynett.no> wibbled:
On 09/04/2025 21:11, bart wrote:
The sets of parameter names are all different (and that's in the same
file!); which is the official set?
>
C has had flexibility here for all sorts of reasons. But if named
parameters were to be added to the language without significant extra
syntax, then this particular issue could be solved in at least two very
simple ways. Either say that named parameter syntax can only be used if
Anyone who really wants named parameters at function calling can already do
this in C99:
struct st
{
int a;
int b;
int c;
};
void func(struct st s)
{
}
int main()
{
func((struct st){ .a = 1, .b = 2, .c = 3 });
return 0;
}
Ha, ha, ha!
Those aren't named parameters. It would be a dreadful solution anyway:
* Each function now needs an accompanying struct
* The function header does not list the parameter names or types
* Inside the function, each parameter name needs to be qualified (s.a etc)
* All fields can be omitted (presumably to default to all-zeros) which may not be what is desired
* When structs are passed by-value as is the case here, it can mean copying the struct, an extra overhead
* It can also mean construction an argument list in memory, rather than passing arguments efficiently in registers