emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (0 <= i && i < N) is not "backwards"


From: Pascal J. Bourguignon
Subject: Re: (0 <= i && i < N) is not "backwards"
Date: Mon, 25 Mar 2013 00:53:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Emacs trunk bzr 112126, installed with the commit log
> "Reorder conditions that are written backwards",
> changed a lot of Emacs code, typically to replace expressions
> like "0 < i" with expressions like "i > 0".
>
> This sort of stylistic change shouldn't be introduced without
> discussion.  I often prefer "<", as it causes textual
> order to reflect numeric order.  This is not just a personal
> preference; it's a common style used in other GNU projects.
> Removing this style en masse is not called for, particularly
> in places where the code is checking for values in range.

Indeed, writing all comparisons only with < or <= is one of the only two
things I learned about programming from university.  (The other one being
to write IFs so that the error case is processed first (assumedly being
smaller)).

Also, for lispers: in lisp, we write: (plusp i), not (i plusp).
Hence:                                (0<    i), not (i >0).

                                      (null  r)
Hence:                                (0==   r)


> In one or two places the change may have introduced a bug,
> as "! (0 < X)" is not equivalent to "X <= 0" when
> X is floating point, because of NaNs.
>
> I suggest reverting the change and discussing it before
> applying.




-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]