Liste des Groupes | Revenir à cl c |
On 14/12/2024 22:22, Keith Thompson wrote: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 usuallyThose are function *definitions*. Declarations, including function
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;}
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.
Consistency would mean function definitions could be 'bundled' too.
[...]If the language allowed function definitions to be bundled
I don't care about it.
I just wondered why not since such lists are
allowed elsewhere.
[...]>
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?
No of course not. But I'm trying to shed light on the odd rules in
language;
S1; S2; S3;
>
where:
>
#define S1 if (c) a;
#define S2 if (c) {a;}
#define S3 if (c) a
The end result is:
>
if (c) a;; if (c) {a;}; if (c) a;
>
It's messy. Also, is the semicolon considered part of the statement,
or is it administered by whoever is assembling the statements within
the bigger picture?
As I said, the whole thing is starting to look like a hack just so you
/don't/ end up with sequences of semicolons.
Les messages affichés proviennent d'usenet.