4 ms·
Nobody else is admiring typed enumerations? Particularly when using structs this removes a lot of ambiguity if you ignore the indirection to find out the under
by quesomaster9000 3y ago
Nobody else is admiring typed enumerations?
Particularly when using structs this removes a lot of ambiguity if you ignore the indirection to find out the underlying type of the enum (or encode it in the name hungarian style).
enum D : uint8_t {
A = 0,
B = 1,
C = 2
}
typedef struct {
D f;
} __attribute__((packed)) E;
assert(sizeof(E)==1);
etc. could make grokking protocol declarations with enums less onerous and requiring one less level of indirection.
- maccard 3y agoI'm a c++ programmer and finding it hard to be excited about things we added to the language 12 years ago.
- quesomaster9000 3y agoAs a D programmer, why haven't you caught up yet?
- loeg 3y agoAs a sneering C++ programmer, why are you even reading / commenting on a new C standard? This is basically a "if you don't have anything nice to say, don't say it" situation.
- tom_ 3y agoThe same goes for C programmers with a chip on their shoulder! There is a downvote button.
- maccard 3y agoHonestly, because there's very little c++ content here on HN and a relatively large amount of C content. Most of the C content is full of people saying "we don't need X from C++" but the reality is most of these things have significant uses
- loeg 3y agoNeither of those statements really matches my experience with HN (high C to C++ content ratio, lots of comments rejecting advances first added to C++). I totally agree some of these things are very useful and I'm glad to see them formalized in C (even years later than C++).
- paulddraper 3y agoI wouldn't speak too loudly on that high horse. The HN Rust Gang will find you.
- maccard 3y agoThey're too busy looking for their vowels to reply here. Joking aside, I've a healthy amount of respect for rust, and I hope that many of the ideas make their way into other language. The terseness, heavy use of macros, _insane_ compile times (and that's coming from someone who writes templates in c++), general assumption that you're on Linux from third party crates, and IDE support combine for something that just isn't usable for me just yet. Maybe in a few years!
- david2ndaccount 3y agoClang has had it as an extension for a long time