Liste des Groupes | Revenir à cl c |
On 13/07/2024 10:37, David Brown wrote:Of course it matters. /You/ can make changes to /your/ tool with a total disregard for the consequences. You don't need to care about the effects it might have on the rest of the tool, because it's a small and self-contained tool. You don't need to care about how it affects code other people have written over the decades - you are only interested in the code /you/ wrote (if you even care about that). You don't need to care about how it will affect code other people will write in the future. You don't need to care about how it might affect possible language changes in the future.
If you say stupid things, repeatedly,Start applying a bit of your intelligence (you say stupid things sometimes, but I know you are far from stupid), and you'll find the level of conversation going up.You are spectacularly missing the point. IT DOESN'T WHOSE TOOL IT IS.
>I made the tweak to see how hard it would be to detect value-arrays declared in parameter list (it was very easy), and what the consequences would be on existing code (significant).>
No, the consequences are non-existent because no one uses your tool, and no one will ever copy that change in other tools (of significance).
Somebody could have done the same exercise with gcc, and come to the same conclusion: too many programs use array parameters.Did it never occur to you that most people use array parameters /correctly/ ? Some people don't like using them (I'm not a big fan myself), but other people like them.
Code that uses that syntax would no longer work. It's quite simple, really.>What WOULD be the effect if a compiler did that? How would a particular codebase be affected?>>
The example I posted showed a type (const char* x[]) where there was no advantage to having that value array notation. Using 'const char**' would be a more accurate description of the actual parameter type.
>
You can write your code the way you want to write it - it will not change the way anyone else writes their code. It really is that simple. Why is this so difficult for you to understand?
>
Do you really suppose that if /you/ make "foo(char x[])" a syntax error in /your/ compiler, it will have the slightest effect on how other people write their C code?
You can just modify a compiler and try it, which is what I did. What difference does it make which compiler it is? You just have a blind, irrational hatred for anything I do.No, I just have a more realistic idea of the influence you have, and of what is involved in changing real tools used by other people, or changing real languages used by other people.
Another way to do it is for someone to painstakingly go through every line of a codebase by hand, expanding macros and typedefs as needed, and checking whether any parameters declared top-level array types.In what universe would it be a good idea to change compilers to stop them compiling existing correct working code?
I think if you were given that job to do, then applying my toy compiler wouldn't be so bad after all!
It has warnings on the risky parts - such as applying "sizeof" to parameters declared to look like arrays. That's all you need, really. (I'd prefer if that kind of warning were enabled by default.)Or on what other C compilers do? Or on how half a century of existing C code is written?gcc could conceivably have an option that detects and warns about that.
>
>
Personally, I don't like that C allows something that /looks/ like arrays can be passed to functions, but doesn't work that way.
Whoever is thinking about doing that might well do a test exactly like mine.No, they would be better off allowing established C syntax to work correctly while offering warnings where possible about likely code errors. That's what real tools do.
But that's just /my/ code. I am not in favour of changes that break other people's code.I don't think I have ever written a function with an array-like parameter - I use a pointer parameter if I mean a pointer, or have the array wrapped in a struct if I want to pass an array by value.So all /your/ code would still pass; great!
That's just nonsense - and you know it.But I don't think my opinions make a difference to C, and even if I were elected dictator of C for a day, I don't think my opinions should count more than any one else's - including those that like the way C works hereHalf of the programming language you call "C" is defined by the way you invoke your compiler. So that already allows for myriad, slightly different dialects.
Somebody had to think up all those options, and they would have been influence by people's opinions. This is just one more, which I would happily have as a default.If someone thought that it would be a good idea to warn about using array syntax in function parameter declarations, then it could certainly be added to tools as a /warning/. That's totally different from disallowing it in the language.
You really don't understand how people use compilers, do you? You know how /you/ use /your/ language and /your/ tools, but the idea of there being other programmers in the world, with different needs and preferences, seems beyond you sometimes.And I don't confuse my opinions or preferences with how C actually works and how it is actually defined, and I certainly don't spread such confusions and misunderstandings to others.C does that well enough by itself. There are any number of behaviours where: (1) saying nothing and passing; (2) warning and passing; (3) reporting an error and failing are all perfectly valid.
You just choose which one you want, at least if using an equivocal compiler like gcc.
This is like taking an examination and being able to choose how strictly it should be marked! Yeah, I think I'll got a pass today...
Les messages affichés proviennent d'usenet.