Ask HN: What extension would you like to see in the next C standard?
There are some interesting new proposals for what will likely become c23. Some I like:
- true and false as first-class language features: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2655.pdf
- a fundamental type for N-bit integers: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2646.pdf
- auto, closures and lambdas: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2638.pdf
- preprocessor embed to include binary files: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2592.htm
- typeof: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2593.htm
- defer: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2542.pdf
What else would you like to see in the next revision of the C programming language?
13 comments
[ 4.1 ms ] story [ 39.0 ms ] threadI really hope they approve the following:
It would lead to cleaner code without excessive macro magic; only where would be needed.[1] https://gustedt.wordpress.com/2020/12/14/a-defer-mechanism-f...
Function overloading and default parameters. They're just too nice not to have.
Closures and lambdas (mentioned)
(I’m looking for honest dialogue and not trying to be combative)
- "goto case" and "goto default"
- Using ?: with nothing in between, like GNU C does. This is a feature I often use.
This goto case extension would be, if you write "goto default" inside of a switch block, then it go to the default label, and if you write "goto case" and an expression, it evaluate the expression and go to the case label that matches the result, or to default if there isn't a match.
The ?: with nothing in between is documented in the GNU documentation, although I can also explain here: If whatever is before the question mark is true then that value is used (without evaluating it twice); if false, then instead whatever is after the colon will be used.