Post #1884816
2026-05-02 14:43 UTC
Replies (9)
-
@poliorcetics@social.treehouse.systems 2026-05-02 14:52
@thephd@pony.social I am confused but it seems cool
-
@fay59@tech.lgbt 2026-05-02 20:31
@thephd@pony.social if you allowed “auto x” for a default case, `#define bar(X) _Generic(X, auto x: …)` could become the least bad way to bind the expansion of a preprocessor macro to a variable inside a single expression
-
@thephd@pony.social 2026-05-02 14:47
@simontatham -- not to bother you but since this is now live you can probably kick the tires a little bit on it in Godbolt. I think it solves most of your concerns (save what happens in the default: branch!). Still need to figure out if I need braces around the _Generic bits to see if it works.
-
@whitequark@social.treehouse.systems 2026-05-02 14:44
@thephd whoaaaa this is a big deal
-
@dysfun@social.treehouse.systems 2026-05-02 15:00
@thephd very cool. is it going to happen to iso c?
-
@wren6991@types.pl 2026-05-02 15:03
@thephd wait that's illegal
-
@uecker@mastodon.social 2026-05-02 15:54
@thephd I don' think we need more braces. The scope can be limited as you implemented it.
-
@erisceleste@tech.lgbt 2026-05-02 16:45
@thephd aw hell yea in addition to the primary use, im super excited for an alternative usage it enables which ive wanted for many years: #define let_in(TMP, VAL, EXP) _Generic((VAL) \ , typeof (VAL) TMP: (EXP)) // temporary variables within expressions! int x = let_in(tmp, side_effects(), tmp > 10 ? tmp : tmp - 1); finally you can write a correct max macro lol (what i think of as "lightweight lambdas" - all i want is a name binding, don't need the complexity of anything bigger)
-
@valorzard@mastodon.gamedev.place 2026-05-03 18:41
@thephd ... wait what the hell is happening here? is this like a factory for creating new structs, except the structs are referred by number?