Дана 24/06/21 09:14PM, Markus Wichmann написа:
> Let me offer a counterpoint: Expressiveness. If I make a function return
> a bool, then everyone from the world's worst junior dev to Ken Thompson
> himself will be able to see at the very first glance that the function
> is returning a boolean value. If I make a function return an int, that
> is not so clear.
Maybe a "junior dev" who learned to program in Java or C# would only be
able to see it if _Bool was used instead of int, but the rest of the
world is (idiomatically and intuitively - knowing that logical type in
C is int and how it is usually used, aside from deducing from the name
of the function itself) going to have no problem understanding that
int isalpha(int c);
returns 0 if the parameter c is not a letter, and !=0 otherwise, and
that it perfectly plugs into if-constructs:
if (!isalpha(s[i]))
// ...
This is one of those places where C is closer to machine code/assembler
than, say, level of abstraction (obscurity) of Pascal or Java.
> Isn't it all about familiarity in the end? Or can you articulate what
> parts of C11 and C23 you find objectionable?
Just a few examples:
- C11: bounds checking interfaces (now even suggested for removal)
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1967.htm
- C23: nullptr{_t,}, true/false, _BigInt, "C++ compatibility" - just no.
https://harmful.cat-v.org/software/c++/
The overarching trend seems to be that C is gradually turning into C++
lite with all the keywords, attributes, etc. There's no need for any of
that.
Received on Fri Jun 21 2024 - 23:10:52 CEST