5 ms·
> 4. None of your points support the case of "don't use stdbool" Huh? I was saying that the language did not have to be extended to get a bool typedef. C99 def
by zvrba 14y ago
> 4. None of your points support the case of "don't use stdbool"
Huh? I was saying that the language did not have to be extended to get a bool typedef. C99 defines a new type, _Bool (name from the reserved identifier space), which is different from existing types. stdbool is a simple typedef of _Bool to bool.
Also, introducing bool would have had meaning if implicit conversion to int wasn't allowed. But since it is, it's a useless type.
My viewpoint is that types exist for enforcing semantic constraints; what use of a bool type that allows performing semantically nonsense operation, such as implicit conversion to int in arithmetic context? The C99 committee messed it up big with bool.
- fusiongyro 14y agoAdding it to the language saves us all the work of typedefing it. Which is a very common practice. C's approach to typing is, in general, pretty weak. Mostly they're there so the compiler can decide how much space to set aside. There's no point singling out this particular instance of nonsense when everywhere you turn in C you're greeted by other forms of the same nonsense. There's no point being pedantic about bool if you're not going to be pedantic about all the other types. Enough bikeshedding. Use it or don't.
- zvrba 14y ago> There's no point singling out this particular instance of nonsense when everywhere you turn in C you're greeted by other forms of the same nonsense. By your reasoning, since nonsense already exists, it's pointless to try to do the right thing. And they could have done it.