[PPL-devel] Redundant elses

Roberto Bagnara bagnara at cs.unipr.it
Tue Oct 4 14:57:31 CEST 2005


Matthew Mundell wrote:
> Log message:
> 	Take out two redundant `else' and a redundant `if'.

What do you mean by redundant else?
Notice that source code is more than its semantics: the fact
that with and without the else the behavior is the same is not
a good reason to prefer the version without (or the version with
the `else').
If, in addition, you have something of the form

    if (a)
      ...
    else
      // comment
      return ...

then taking out the else without revising the comment can
do more harm than good.

More generally, the rationale for such changes is as follows:

- either things are left as they are on the grounds that who
   wrote the code knew better if the `else' there was making
   things more readable or not;
- or the issue is raised globally, discussed at length,
   documented in the STANDARDS file and then systematically
   applied to whatever code.

Ciao,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the PPL-devel mailing list