Issue 4705

Timon Gehr timon.gehr at gmx.ch
Sun Sep 18 12:59:25 PDT 2011


On 09/18/2011 09:38 PM, Simen Kjaeraas wrote:
> On Sat, 17 Sep 2011 16:06:44 +0200, Timon Gehr <timon.gehr at gmx.ch> wrote:
>
>>>> xyz!"a<b"([1,2,3,1,2,3]) is 1
>>>>
>>>> xyz!"a>b"([1,2,3,1,2,3]) is 3
>>>>
>>>> Question is what's a good name for xyz. It returns the element X of the
>>>> range such that pred(E, X) is false for all E in the range. Then we'd
>>>> defined xyzCount and xyzPos and call it a day.
>>> [...]
>>
>> That is the definition of a minimum. pred is the order relation and
>> the range gives the set. Ergo xyz=min. But that is were we are.
>
> Except that min does not mean 'apply this ordering to this set, and then
> do min on it' to most people.

It really should. I'd hate to see the custom predicate go away.

> Extremum is a better choice not because it
> better describes what it does, but precisely the opposite - people do not
> intuitively 'understand' it, and thus look it up.

If someone does not understand the point of the custom predicate, they 
will look up that too. The effect of having meaningless, or, as in this 
case, just plain wrong, function names is merely decreasing 
productivity, there are never positive implications.

> That said, I agree
> extremum is not a good name for xyz, but min is horrible.
>

min is not horrible, but good; it explains correctly what the function 
does. extremum does not, ergo it is horrible for all definitions of 
horrible function names known to me.

>
>>> What about ultimum? It means the last or the outermost.
>>>
>>
>> As long as the function computes a least element, any names other than
>> leastElem* or min* are just confusing. 'ultimum' is not specific
>> enough. "Does it compute a least element or a greatest element?" The
>> approach of having a name that includes both max and min cannot work
>> in a satisfiable way for that reason.
>
> Excepting of course the possibility that someone at some point might
> read the documentation...
>

feedMyDog();

That is a function that will do your laundry. If you don't remember the 
function name tomorrow, go look at the documentation (for reference, the 
function that will feed your dog is named stealMyUnderwear())



More information about the Digitalmars-d mailing list