Issue 4705
Christophe
travert at phare.normalesup.org
Mon Sep 19 02:13:14 PDT 2011
"Simen Kjaeraas" , dans le message (digitalmars.D:144599), a écrit :
> That said, there are cases where a < b is not enough, owing to some
> types not having a nice and simple comparison. Hence, binary
> predicates should also be allowed. I just feel that in the general
> case, binary predicates dilute the meaning of min/max. Would you
> consider this code good?
> min!"a > b"(range);
Programers should know that the appropriate predicate for a comparison
is the less function. If "a>b" is your less function, the the minimum of
the range is indeed the maximum of the range ranked with the ordinary
comparator, but it's still a minimum using this compararison function.
Of course, writing min!"a>b" is not that good, because it is confusing,
and the programmer should have used max!"a<b", but you cannot always
prevent the programmer from doing stupid things. You can help him by
providing max along with min so he does not have to do something like
this. (and provide maxPos along with minPos).
extremum would make me think both maximums and minimums are returned.
--
Christophe
More information about the Digitalmars-d
mailing list