News for hackers. Stuff that matters.
Re:Obvious Things C Should Do by TinkersW on Saturday January 11, 2025 @06:41PM (#42669893)
C++ has all of these except forward referencing declarations(though Importing Declarations requires modules which nobody uses yet).

I'm not sure why forward reference declarations is needed nowadays(or if it really is from a language standpoint).

C could probably copy C++'s constexpr & static_assert stuff to get the first 2.

Re:Obvious Things C Should Do by dccsillag on Saturday January 11, 2025 @07:56PM (#42670248)
If I'm not mistaken, the treatment of forward declarations proposed in the article actually breaks the C standard, which would be a rather pressing concern. As far as I am aware, that is the reason why things are the way they are right now in C land.

(In the past, there were more legitimate concerns on the ease of implementation. Nowadays, as the article points out, they are pretty moot, other than having to keep backwards-compatibility.)

I'm also rather bothered that on the bit on const execution in the article, there was no discussion on how to deal with functions that may not terminate or take rather long to execute. Especially considering the unit tests motivation, this seems like a rather blaring omission.

Re:Obvious Things C Should Do by WalterBright on Saturday January 11, 2025 @09:29PM (#42670754)
How does it break the C Standard?

> how to deal with functions that may not terminate or take rather long to execute

Control-C, the same as when running any executable that shouldn't be taking that long. It doesn't solve the halting problem :-/

Re:Obvious Things C Should Do by UncleEntity on Saturday January 11, 2025 @11:25PM (#42671267)
So a single typo DDoSes the entire Red Hat buildbot fleet?
Re:Obvious Things C Should Do by kstenerud on Saturday January 11, 2025 @11:40PM (#42671321)
You set a timeout, like in any robust CI.
Re:Obvious Things C Should Do by WalterBright on Saturday January 11, 2025 @07:11PM (#42670038)
Nobody uses C++ modules because they are clumsy to use. D's are easy. Note: anyone is free to copy D's module design. It's the best one out there.

> I'm not sure why forward reference declarations is needed nowadays

The article gives reasons. Although they aren't necessary, they are deleterious to code layout which becomes a slave to the declaration order rather than aesthetic order.

> C++'s constexpr

is still lagging behind D's, after 17 years of development. In D, the garbage collector makes memory allocation in it trivial. Furthermore, only the path taken through a function needs to be CTFE-compatible, the path not taken does not.

Re:Obvious Things C Should Do by zeroonetwothree on Saturday January 11, 2025 @11:34PM (#42671301)
Robert Frost would approve
Re:Obvious Things C Should Do by pjmlp on Monday January 13, 2025 @05:24AM (#42681983)
Re:Obvious Things C Should Do by loeg on Saturday January 11, 2025 @10:57PM (#42671172)
C's already got static_assert; just missing constexpr.
Re:Obvious Things C Should Do by pjmlp on Monday January 13, 2025 @05:24AM (#42681979)
Office team does use them.

There is Vulkan based modules library.

fmt has modules support.

Me and several others already use modules in some extent.

That is a bit more than nobody.