3 ms·
Why have comparison callbacks return this enum enum c7_order {C7_LT, C7_EQ, C7_GT}; instead of a signed int which seems to be the idiomatic way in C?
by sersnth 7y ago
Why have comparison callbacks return this enum
enum c7_order {C7_LT, C7_EQ, C7_GT};
instead of a signed int which seems to be the idiomatic way in C?
- codr7 7y agoBecause I always end up switching on the return value, and switching on enums is a lot nicer than ints. Especially when there is no agreement on what values are returned, LT is mostly -1 but is often specified as simply less than zero. When you have a finite set of cases, enum is just the right solution period. I have no idea why people still insist on using ints.