[email protected] writes:

> I just used inline conditionals as an example of a code style where
> conditions are inlined. More generally, there seem to be two views on
> readability:
>
> One could be summarized as "Don't do more than one thing in one line"
> (for example inline conditions that might come as evaluation of a
> boolean expression within an assignment, or inline conditionals). The
> code is easier to "parse" for a new reader and easier to debug. This
> view seems to be popular in the Java world.
>
> The other take is "Compact code is more readable" as in the proposed
> change. If an experienced reader recognizes patterns such as "Boolean
> evaluation inside an argument" the code may be faster to read (unless
> the code is too compact).

We are not talking about compact code here but code duplication.  Since
the duplication occurs in different execution paths, it is not per se a
performance issue (though branch prediction can be expensive nowadays),
but it means having to read both branches to figure out what is doing
done.

It also means having to do a complex text comparison to figure out how
the two different code paths differ.

Personally, I find having to parse things like

if (condition != false) then somethingcomplicated(true)
                        else somethingcomplicated(false)

annoying and contorted.

-- 
David Kastrup


_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to