Am Thu, 04 Oct 2012 16:12:43 +0200 schrieb "Simen Kjaeraas" <simen.kja...@gmail.com>:
> On 2012-27-04 07:10, Walter Bright <newshou...@digitalmars.com> wrote: > > >> * OpCmp returning an int is fugly I r sad > > > > How else would you return a 3 state value? > > enum Comparison { > Before = -1, > Same = 0, > After = 1, > Unordered = NaN, > } > > I'm not saying it should be done, but it would be more readable > (and more cmoplex to write). a) There is no integer NaN and floating point is a no-go. b) If you mix sortable and unsortable most algorithms fail. Otherwise an enum solution is good, but a bit longer in code: auto rel = a.OpCmp(b); if (rel < 0) ...; else if (rel > 0) ...; else ...; vs. if (rel == Comparison.Before) ...; else if (rel == Comparison.After) ...; else ...; And in many cases right now you can just "return a - b"; -- Marco