4 ms·
I wonder how the "discriminated union" thing is better than an enum + a structure for each type + a structure with a field for the discriminator (the enum) and
by norswap 10y ago
I wonder how the "discriminated union" thing is better than an enum + a structure for each type + a structure with a field for the discriminator (the enum) and an union of all structures. It certainly is much more readable, and idiomatic. And this doesn't add any benefits that I can see.
- dllthomas 10y agoThat's exactly what it's doing. There's no benefit to using these macros except that it's shorter and maybe (?) therefore clearer.
- jonathankoren 10y agoIt's certainly not clearer if we have to guess.
- dllthomas 10y agoGuess what?
- jonathankoren 10y agoI was wondering that same thing. He's hiding a bunch of stuff behind his lutils.h macros, to make it "literate". Using preprocessor macros to try to create new language constructs is pretty much always Bad News(tm). Almost as bad as using C++ operator overloading to completely change the semantics of an operator. (Bitwise or? Yeah, that's some sort of weirdo automatic function nesting thing now, but only here, and 6 lines down.)