Sujet : Re: how to make a macro work as a single line if stmt without braces
De : andreytarasevich (at) *nospam* hotmail.com (Andrey Tarasevich)
Groupes : comp.lang.cDate : 24. Sep 2024, 15:52:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcujmj$384dh$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
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.
-- Best regards,Andrey