On Jun 20, 2017 12:00, "Jacob Champion" <[email protected]> wrote:

On 06/20/2017 09:47 AM, [email protected] wrote:

> Log:
> Make the range test legible
>
Hmm, out of curiosity, is the legibility you mention from the
parenthesization change or the switch to greater-than-or-equal for one side?

<completely trivial nitpick>

I kind of like reading code that has all less-than comparisons, instead of
mixed less-than and greater-than, because it means the logic is closer to
the mathematics and the number line. For example,


I prefer comparisons where the lhs is the variant and rhs is the longer
lived/fixed quantum.


0 < x < 5
becomes
((0 < x) && (x < 5))

y < 1 or 5 < y
becomes
((y < 1) || (5 < y))

This is not a big deal; I just feel like typing about something trivial
this morning. I realize the point of this patch is to fix the off-by-one.


Neither logic would be 'wrong'.

On that note, the extra parens aren't needed for C/C++, OOO rules that ||
and && are the lowest order, but I still find it less obvious. So asking
the compiler to go to some extra effort seems worthwhile. One can argue
that this misleads new programmers into a belief that the parens had an
actual parsing impact, so again there is no one right answer.

Reply via email to