between and among: worth Phobosization?

Walter Bright newshound2 at digitalmars.com
Mon Dec 16 14:10:26 PST 2013


On 12/16/2013 1:47 PM, Brad Anderson wrote:
> On Monday, 16 December 2013 at 20:38:52 UTC, Andrei Alexandrescu wrote:
>> bool between(T, U1, U2)(T v, U1 lo, U2 hi)
>> {
>>     return v >= lo && v <= hi;
>> }
>>
>
> I must say that:
>
>      if (val.between(3, 10))
>
> sure is a lot easier to understand at a glance than:
>
>      if (val >= 3 && val <= 10)
>
> Although there is a problem with the word "between" not being clear about
> whether it is inclusive or not.

Exactly, meaning I'd have to go look at the source code for it, whereas with the 
latter I can see right away what it is. The function is a net programmer time loss.



More information about the Digitalmars-d mailing list