Liste des Groupes | Revenir à cl c |
On 29/11/2024 16:42, David Brown wrote:And the laws of physics allow me to drop a 20 kg dumbbell on my toe. That does not mean that anyone thinks it is a good idea.On 29/11/2024 15:15, Michael S wrote:C's syntax allows a 14-parameter function F to be declared in the same statement as a simple int 'i'.On Fri, 29 Nov 2024 13:33:30 +0000>
Bart <bc@freeuk.com> wrote:
>>* It allows a list of variable names in the same declaration to each
have their own modifiers, so each can be a totally different type
>
They can't have "totally different" types - they can have added indirection or array indicators, following C's philosophy of describing the type by how the variable is used:
>
int x, *y, z[10];
>
Thus "x", "*y" and "z[i]" are all of type "int".
I'd say that F and i are different types! (Actually I wouldn't even consider F to be type, but a function.)Functions have types in most typed languages, including C.
That F(1, 2, 3.0, "5", "six", seven, ...) might yield the same type as 'i' is irrelevant here.No, it is exactly the point - it is how C is defined.
Usually, given these declarations:They are different - but related - types.
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];"const" is allowed here because it is part of the type returned by F().
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!
Here's another puzzler:
const int F();
why is 'const' allowed here? There is no storage involved. It's not as though you could write 'F = 0' is there was no 'const'.
I am not implementing the language. No one else here is implementing it. You have, apparently, implemented at least some of the language while being completely incapable of understanding it. I am surprised that is possible, but it is what you seem to be claiming.C allows this, but I personally would be happier if it did not. As Michael says below, most serious programmers don't write such code.It doesn't matter. If you're implementing the language, you need to allow it.
If trying to figure out why some people have trouble understanding, it's something to consider.I have met a good many C programmers over the years, and some of them have had misunderstandings. I have never heard of anyone who comes close to your level, however.
It's also something to keep in mind if trying to understand somebody else's code: are they making use of that feature or not?So what is your preferred solution? Whine endlessly on newsgroups for decades on end about the same things you dislike, to people who have absolutely no influence on the thing that bothers you? How productive has that been for you?
So this is a wider view that just dismissing design misfeatures just because you personally won't use them.
With the kind of C I would write, you could discard everything after C99, and even half of C99, because the subset I personally use is very conservative.You say that as though you think it is a good thing - it is not.
Les messages affichés proviennent d'usenet.