Remix.run Logo
aDyslecticCrow 5 days ago

The boolean type is the massive whaste, not the enum. A boolean in c is just a full int. So definitely not a whaste to use an enum which is also an int.

And usually you use operations to isolate the bit from a status byte or word, which is how it's also stored and accessed in registers anyway.

So its still no boolean type despite expressing boolean things.

Enums also help keep the state machine clear. {Init, on, off, error} capture a larger part of the program behavior in a clear format than 2-3 binary flags, despite describing the same function. Every new boolean flag is a two state composite state machine hiding edgecases.

glxxyz 5 days ago | parent [-]

Not necessarily a waste in all languages. A c++ `std::vector<bool>` efficiently packs bits for example, although it does have its own 'issues'.

verall 4 days ago | parent | next [-]

Yes, this is interestingly considered one of the worst design decisions in C++ history. It's not /the/ worst but it's up there.

aDyslecticCrow 5 days ago | parent | prev [-]

I kinda hate that. It gives the vector very special behaviour for one type in particular, going against the intuition behind how both boolean and vector works everywhere else in the language.

Id prefer if they just added std::bitvector.