Sujet : Re: question about linker
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.cDate : 08. Dec 2024, 11:52:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vj3tqa$3o9ef$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
User-Agent : Mozilla Thunderbird
On 07/12/2024 22:18, Bart wrote:
On 07/12/2024 21:00, David Brown wrote:
<snip purely subjective opinion on unrealistic code>
You mean that /real/ example where a function needed a type written 6 times instead of once? OK.
I'd be curious about how you'd write such a function; maybe all your functions only have one parameter, or they are always of mixed types.
Having so many parameters in a function is a sign of a bad interface design - the more parameters, the poorer the design. Occasionally having 6 parameters might be the best choice in a particular case, but it is going to be rare - most functions have far fewer. And it's okay if things are a bit awkward or harder to write for something that should be rare, and is rare in practice.
The problem is not so much when defining or declaring the function - it is when /using/ the function. C does not have named arguments, and it is extremely easy for code calling a function of many parameters to mix them up (especially if they are the same type).
I'd have been quite happy if C had a syntax along the lines of
int foo(int a, b, c, double x, y, z);
for declaring functions. It can't quite follow the same pattern as for declarations of variables (because then you'd need a semicolon after the "c" above), but it would be close.
But C doesn't have a syntax like that, and the syntax it has is rarely an issue for anyone.