4 ms·
If you don't understand that tag_union(&a, SomeThree) throwing a compile time error is functionally equivalent to static_assert(), then I see no point in contin
by huhtenberg 9y ago
If you don't understand that tag_union(&a, SomeThree) throwing a compile time error is functionally equivalent to static_assert(), then I see no point in continuing this exchange. Ditto for the invariant checking - OP's original code already covered that with its assert(). In fact, that assert() is what this whole thing is about.
All points in your opening "garbage" comment were trivial nitpicks, which would've been fine if you didn't decide to express them by trashing other person's code in an overly confident manner. I don't appreciate that, just as I don't appreciate you trying to wiggle out from this exchange on technicalities.
- klodolph 9y agoYes, you're right, tag_union does throw a compile time error, I didn't read that correctly. By your earlier comment I was primed for a `_Static_assert` and when I didn't see that. I thought it had been left out entirely rather than reimplemented in a different manner. On the subject of tone--I honestly believe that the original code has severe subjective design flaws and objective implementation errors, and since the post was gathering upvotes but no critique I was worried that people believed that the code was correct. There are still some nitpicks about your new version, but these are fairly minor in my view (the use of reserved identifiers is pretty tedious and easily avoided). The remaining non-nitpick, what I consider to be a show-stopper, is that you can't switch on the tag. 90% of the time when I'm using a tagged union, I'm doing switch (evt->type). While we can substitute a chain of if/else, I'm not fond of the ergonomics and I would prefer a traditional enum. This is a subjective trade-off, however. Your responses would have been fine if they were criticisms of my argument or of the tone I took. Perhaps I crossed the line, and you called me on it? But these comments are unacceptable ad hominems: > Oh, the horror. It's C, a language that generally expects you to know what you are doing. > Wit beyond measure, fascinating.