Re:C will never stop you from making mistakes
by MaxBarraclough on Monday August 10, 2020 @10:08AM
(#24109388)
The problem is that it doesn't reflect how the C language really works. More specifically, it is misleading in multiple declarations, see the sibling reply at https://news.ycombinator.com/item?id=24109267
[ Parent
| on HN ]
Re:C will never stop you from making mistakes
by Ragnarork on Monday August 10, 2020 @12:02PM
(#24110694)
One could argue it's wrong to do multiple declarations like that, and the whole argument collapses to mostly a matter of preference.
Re:C will never stop you from making mistakes
by MaxBarraclough on Monday August 10, 2020 @12:20PM
(#24110906)
Even if your coding style prohibits multiple declarations, you still don't escape the fact that in C, the asterisk binds to the variable identifier, not to the type. It crops up again in the function pointer syntax:
void *(*foo)(int *);
foo is a pointer to a function which accepts a pointer-to-int and returns a pointer-to-void.( Taken from https://www.cprogramming.com/tutorial/function-pointers.html )
Thanks, this is the best example I've seen.
Re:C will never stop you from making mistakes
by saagarjha on Monday August 10, 2020 @04:47PM
(#24113801)
You can call a feature of a language misguided, but you can't call it wrong; that's just how C does identifiers. Sure, in your "cut out the parts of C that don't fit into my model" you can make it work, but that's not C.