Sujet : Re: question about linker
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 14. Dec 2024, 23:22:03
Autres entêtes
Organisation : None to speak of
Message-ID : <877c81vras.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
On 14/12/2024 20:17, Waldek Hebisch wrote:
Bart <bc@freeuk.com> wrote:
[...]
For the same reason that f(1 2 3) might be unambiguous, as usually
it's written f(1, 2, 3).
>
Actually, since C likes to declare/define lists of things where other
languages don't allow them, such as:
>
typedef int T, U, *V;
>
struct tag {int x;} a, b, c;
>
enum {red, green} blue, yellow;
>
I couldn't quite see why you can't do the same with functions:
>
int F(void){return 1;}, G(void){return 2;}
Those are function *definitions*. Declarations, including function
declarations, can be bundled :
int F(void), G(void); // not suggesting this is good style
Definitions that are not declarations, such as function definitions,
cannot.
I thought you liked consistency.
If the language allowed function definitions to be bundled, you could
write something like :
int F(void) {
// 30 lines of code
}, G(void) {
// 50 lines of code
}
Is that what you want?
[...]
Now that you mention it, why not? In:
>
if (c) s1; else s2;
>
s1 and s2 are statements, but so is the whole if-else construct; why
doesn't that need its own terminator?
Because if it did, you'd need multiple semicolons at the end of nested
statements. Is that what you want?
You seem to be pretending that there's some principle that all
statements should be terminated by semicolons. There is no such
principle, and there are multiple kinds of statements that don't
require a trailing semicolon.
This is legal in C: {}{}{}{}.
>
As I said, I wouldn't be able to explain it.
I could explain it to you, but I can't understand it for you.
[...]
Identifying the end of /some/ statements shouldn't mean not needing
terminators in those cases. It needs to be a consistent rule.
Why? C's grammar is unambiguous. Given reasonable code layout, most C
programmers don't have any problems determining where statements end.
With your "consistent rule", if you had 5 nested statements (if, for,
while, etc.), you'd have to terminate the entire construct at least 5
semicolons.
Is that really what you want?
[...]
But the exact rules remain fuzzy.
The exact rules are not fuzzy. They're unambiguous, and they work much
better than you're willing to acknowledge.
[discussion of your personal language snipped]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */