Deutsch English Français Italiano |
<v2liar$1avch$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Wed, 22 May 2024 21:50:51 +0200 Organization: A noiseless patient Spider Lines: 64 Message-ID: <v2liar$1avch$1@dont-email.me> References: <v2l828$18v7f$1@dont-email.me> <v2lfvr$1ahhf$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 22 May 2024 21:50:51 +0200 (CEST) Injection-Info: dont-email.me; posting-host="c8dad87a6d02311a34acbc1393ea65af"; logging-data="1408401"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18W+OJm8vbCX1cGElffiETX8Oi/P2HH43M=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:L2noD7l4tucm0X0riNB4UGWNzdk= In-Reply-To: <v2lfvr$1ahhf$1@dont-email.me> Content-Language: en-GB Bytes: 3900 On 22/05/2024 21:10, Malcolm McLean wrote: > On 22/05/2024 17:55, David Brown wrote: >> In an attempt to bring some topicality to the group, has anyone >> started using, or considering, C23 ? There's quite a lot of change in >> it, especially compared to the minor changes in C17. >> >> <https://open-std.org/JTC1/SC22/WG14/www/docs/n3220.pdf> >> <https://en.wikipedia.org/wiki/C23_(C_standard_revision)> >> <https://en.cppreference.com/w/c/23> >> >> I like that it tidies up a lot of old stuff - it is neater to have >> things like "bool", "static_assert", etc., as part of the language >> rather than needing a half-dozen includes for such basic stuff. >> >> I like that it standardises a several useful extensions that have been >> in gcc and clang (and possibly other compilers) for many years. >> >> I'm not sure it will make a big difference to my own programming - >> when I want "typeof" or "chk_add()", I already use them in gcc. But >> for people restricted to standard C, there's more new to enjoy. And I >> prefer to use standard syntax when possible. >> >> "constexpr" is something I think I will find helpful, in at least some >> circumstances. >> > > So I'm currently writing some code (you can follow my progress on > github, it is a new branch in the Baby X resource compiler project). And > it's just standard well understood algorithm code to manipulate XML > trees. And I certainly don't feel the neeed for static_assert. I use static assertions everywhere I can. I used them long before C11 added them to the language, using a somewhat messy macro to force an error if the assertion fails. They catch mistakes, they document assumptions, they make code clearer to the reader. And they do so with zero cost in code space or run-time, and no more effort than writing a comment. I find it hard to understand why anyone would actively choose not to use them. > But even > boolean type and const. Bool is much more than "int 0" and "int 1". And it is significantly clearer in code. (Sometimes, of course, a specific enumerated type is clearer than bool or int.) Const documents the code, makes the action of a function clearer to the reader, and helps catch mistakes. These are all things that make the language better, and have done so for the past 25 years. > Of course quite alot of the functions don't > actually change the structures they are passed. But is littering the > code with const going to help? And why do you really need a boolean when > an int can hold either a zero or non-zero value? > > And don't you just want a pared down, clean language? > I want a language with the features I need and that help me to write good clear code. Minimal is not helpful, any more than needlessly complex is helpful.