Liste des Groupes | Revenir à cl c |
On 09/24/24 7:36 AM, Tim Rentsch wrote:
>My long-standing habit is to write this>
>
if(x) bar(x);
>
or this
>
if(x){
bar(x);
}
>
but never this
>
if(x)
bar(x);
>
The reason for this habit is that many years ago I got bitten by
trying to add a line in the last case. The habit subsequently
adopted has proven very effective at eliminating such errors.
It is just weird.
>
This is no different from insisting in using "Yoda conditions",
claiming that "many years ago I was bitten by an accidental =
in place of ==".
In reality we all know that regardless of how many scary
stories someone might tell about dangers of accidental
assignment in place of comparison, it just does not happen.
There's no such issue. People just don't make this mistake.
The same applies to
>
if(x)
bar(x);
>
This is the right thing to do. It is the most readable and
elegant way to write a simple `if`.
And the dreaded "one day you will add a line and suffer" just
doesn't happen. There's no such issue. People just don't make
this mistake.
Les messages affichés proviennent d'usenet.