News for hackers. Stuff that matters.
Re:C: Simple Defer, Ready to Use by worik on Monday January 06, 2025 @02:58PM (#42614912)
Does C really need this?

Do languages need to grow in this way?

The overriding virtue of C is simplicity.

Re:C: Simple Defer, Ready to Use by vkazanov on Monday January 06, 2025 @03:08PM (#42615061)
Yes it does, and numerous projects already use variants of this trick.
Re:C: Simple Defer, Ready to Use by fuhsnn on Monday January 06, 2025 @03:33PM (#42615384)
Re:C: Simple Defer, Ready to Use by pjmlp on Monday January 06, 2025 @05:47PM (#42616954)
That was lost long time ago, after K&R C became part of WG14.
Re:C: Simple Defer, Ready to Use by ahoka on Monday January 06, 2025 @05:56PM (#42617044)
C semantics are far from simple.
Re:C: Simple Defer, Ready to Use by cryptonector on Monday January 06, 2025 @06:51PM (#42617517)
> Does C really need this?

Yes.

> Do languages need to grow in this way?

Yes.

> The overriding virtue of C is simplicity.

C is not simple. It used to be, but it's not been for a long time.

Re:C: Simple Defer, Ready to Use by cassepipe on Monday January 06, 2025 @08:25PM (#42618188)
Re:C: Simple Defer, Ready to Use by jefbyokyie on Monday January 06, 2025 @07:37PM (#42617873)
> Does C really need this?

No.

> Do languages need to grow in this way?

No.

> The overriding virtue of C is simplicity.

It's no longer simple, especially not with the C11 memory model (which got retrofitted from C++11, and is totally incomprehensible without reading multiple hundreds of pages of PhD dissertations); however, gratuitously complicating C shouldn't be done.

Re:C: Simple Defer, Ready to Use by Quis_sum on Tuesday January 07, 2025 @04:23PM (#42627687)
C definitely does not need this - in fact I would go as far and consider it harmful.

I agree that a feature like this could be useful, but then there are other useful features which should be added too. Where do you stop? I hope the C standards committee does not succumb to the feature bloat trend we see in many other languages (hand on heart: how many people fully understand/master all of C++/23's features?).

Need proper arrays instead of pointers to contiguous parts of memory which are interpreted as arrays? Proper strings (with unicode)? Etc. - use a different language suitable for the job.

We really need to let go of the notion that complex software must be written in a single language. Use C for the low level stuff where you do not need/want an assembler or where you want full control. For everything else there are more suitable tools.