Liste des Groupes | Revenir à cl c |
Bart <bc@freeuk.com> writes:(So it would have a different type from E declared on in the same declaration:
[...]C's syntax allows a 14-parameter function F to be declared in the sameYes (except that it's a declaration, not a statement) :
statement as a simple int 'i'.
int i = 42, F(int, int, int, int, int, int, int,
int, int, int, int, int, int, int);
Are you under the impression that anyone here was not already aware of
that? Would you prefer it if the number of parameters were arbitrarily
restricted to 13?
Do you think that anyone would actually write code like the above?
C generally doesn't impose arbitrary restrictions. Because of that,
it's possible to write absurd code like the declaration above. 99% of
programmers simply don't do that, so it's not a problem in practice.
I'd say that F and i are different types! (Actually I wouldn't evenNeither F nor i is a type. i is an object (of type int), and F is a
consider F to be type, but a function.)
function (of type int(int, int, int, int, int, int, int, int, int, int,
int, int, int, int)).
That F(1, 2, 3.0, "5", "six", seven, ...) might yield the same type asIt's relevant to the syntax. i and F can be declared in the same
'i' is irrelevant here.
declaration only because the type of i and the return type of F happen
to be the same. If F returned void, i and F would have to be declared
separately.
Which, of course, is a good idea anyway.
You're posting repeatedly trying to convince everyone that C allows
ridiculous code. We already know that. You are wasting everyone's time
telling us something that we already know. Most of us just don't obsess
about it as much as you do. Most of us recognize that, however
convoluted C's declaration syntax might be, it cannot be fixed in a
language calling itself "C".
Most of us here are more interested in talking about C as it's
specified, and actually trying to understand it, than in complaining
about it.
Usually, given these declarations:No, the object D unambiguously has type int[3][4][5]
>
int A[100]
int *B;
int (*C)();
>
people would consider the types of A, B and C to be array, pointer and
function pointer respectively. Otherwise, which of the 4 or 5 possible
types would you say that D has here:
>
int D[3][4][5];
>
It depends on how it is used in an expression, which can be any of &D,
D, D[i], D[i][j], D[i][j][k], none of which include 'Array' type!
Would you write "const int F();"? Or would you omit the "const"? HowIt's another point of confusion. In my language I don't treat function declarations like variable declarations. A function is not a variable. There is no data storage associated with it.
does the fact that "const" is allowed inconvenience you?
Les messages affichés proviennent d'usenet.