Hacker News new | ask | show | jobs
by sersnth 2361 days 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?
1 comments

Because 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.