Conversation

Björkus "No time_t to Die" Dorkus

Defer has landed in Clang and will (probably, most likely) land for Clang 22! Should show up in Godbolt within the next 48 hours or so, too:

https://github.com/llvm/llvm-project/commit/71bfdd13040328bc83b520d09eee847fd2b7f82c

3
4
1

@thephd now if only I could use this on php-src ;-;

2
0
0

@Girgias set-reminder-5-years: add _Defer E V E R Y W H E R E

0
0
0

@thephd C programming hobbyists(noob) here. Defer in other languages seems to have a couple uses but what's jumping to my mind for C is putting my memory allocation and freeing of that memory next to each other so it's easier to keep track?

Also is Godbolt another name for Compiler Explorer?

1
0
0

@CyberB @thephd defer is mostly here to give peace of mind of "i won't forget to clean up this thing", much like in other languages, and ensures you don't need to handle it in every case, which, in case of error, could lead to errors like use after free, or double free

and yes godbolt is another name for compiler explorer

0
0
0

@Girgias @thephd maybe in a few years we'll be able to use it in codebases

0
0
0

@thephd why every single new syntax change in the latest C standards feels wrong. I wish we could just see better good practices and simplicity enforced to avoid mistakes, not more ways to introduce bugs hard to spot

1
2
1
@pancake @thephd C is pretty old language at this point. You may want to take a look at Rust, it is more of "start from scratch" and brings "no undefined behaviour" benefit.
1
0
0

@pavel @thephd ive been picking rust many times since its inception, but it never ends up attracting me enough to decide to do anything with it

0
0
1