3 ms·
Maybe not then, but we basically have our own poor man's template system now: #define array(T, N) struct array##T##N { T value[N]; } void copy(array(i
by glouwbug 26d ago
Maybe not then, but we basically have our own poor man's template system now:
#define array(T, N) struct array##T##N { T value[N]; }
void copy(array(int, 32)* x, array(int, 32)* y) {
*x = *y;
}
int main() {
array(int, 32) x;
array(int, 32) y = { 1, 2, 3, 4 };
copy(&x, &y);
}
With (rumors of) lambdas and defer on the way, C is going the way of classic WoW.
https://en.wikipedia.org/wiki/C29_(C_standard_revision) https://en.wikipedia.org/wiki/C29_(C_standard_revision)
- warmwaffles 26d agoI remember `defer` being up for consideration for the last consortium but it got yanked. Lambdas would definitely be nice to have.
- glouwbug 26d agoSeems like its in C29, but who knows. I've waited since 2009 for just about anything
- warmwaffles 26d agoC29 is shaping up to be some quality of life changes. And it looks like clang has a lot of it implemented already. GCC seems to be implementing some of them. `countof(thing)` seems handy so I don't have to define some constant and use them in both places.
- leptons 26d ago>C is going the way of classic WoW What does this mean?
- omani 26d agoit means C is going the way of classic World of Warcraft.
- mid-kid 26d agoWhat does that mean?
- glouwbug 26d agoWoW released a steady stream of expansions from 2004 to present day. At some point players wanted the old game, so Blizzard released WoW 2004, known as classic, in 2018, and reran the stream of expansions, stopping before any mass enshittification. You can draw the same parallels with C and C++, where C began picking the best from C++ in 1999, 2011, 2023, and soon to be 2029, and carving its own "classic" path. We even have our Herb Sutter: Jens Gustedt
- kllrnohj 26d agoExcept people aren't leaving C++ for C, if they're leaving it at all they're likely leaving it for Rust or some other memory safe language.
- uecker 26d agoWell, I was leaving C++ for C. I found this unburdened my mind from quite a lot of distracting complexity. For this reason, I am also not really tempted by Rust.
- Dylan16807 25d agoIs the rumored lambda different from a normal function declaration in a bad way? I think defer is good. It's a common type of control flow that's usually done with gotos and mistakes, and I'd say it's slightly less complex than the for loop syntax.