Re: how to make a macro work as a single line if stmt without braces

Liste des GroupesRevenir à cl c  
Sujet : Re: how to make a macro work as a single line if stmt without braces
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c
Date : 27. Sep 2024, 09:43:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86ldzd5vwp.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Andrey Tarasevich <andreytarasevich@hotmail.com> writes:

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 ==".

Don't be silly, of course they are different.  There is nothing
artificial about surrounding controlled statements with braces.
And writing braceless single-line if()s in cases where there
is only a single controlled statement is something I was already
doing - I didn't adopt it as a reaction to something that
happened with multi-line if()s.

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.

Your view is contradicted by objective reality.

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`.

I think you need to learn the difference between a statement
of opinion and a statement of fact.

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.

Making a false statement twice doesn't make it true.

Date Sujet#  Auteur
21 Sep 24 * how to make a macro work as a single line if stmt without braces61Mark Summerfield
21 Sep 24 +- Re: how to make a macro work as a single line if stmt without braces1Lawrence D'Oliveiro
21 Sep 24 +* Re: how to make a macro work as a single line if stmt without braces50David Brown
21 Sep 24 i`* Re: how to make a macro work as a single line if stmt without braces49Andrey Tarasevich
21 Sep 24 i +- Re: how to make a macro work as a single line if stmt without braces1Bart
21 Sep 24 i +- Re: how to make a macro work as a single line if stmt without braces1Opus
21 Sep 24 i +* Re: how to make a macro work as a single line if stmt without braces5Keith Thompson
22 Sep 24 i i`* Re: how to make a macro work as a single line if stmt without braces4Andrey Tarasevich
22 Sep 24 i i +- Re: how to make a macro work as a single line if stmt without braces1Keith Thompson
22 Sep 24 i i +- Re: how to make a macro work as a single line if stmt without braces1David Brown
27 Sep 24 i i `- Re: how to make a macro work as a single line if stmt without braces1Tim Rentsch
22 Sep 24 i +* Re: how to make a macro work as a single line if stmt without braces25David Brown
22 Sep 24 i i`* Re: how to make a macro work as a single line if stmt without braces24Kaz Kylheku
22 Sep 24 i i +* Re: how to make a macro work as a single line if stmt without braces21Bart
22 Sep 24 i i i+* Re: how to make a macro work as a single line if stmt without braces14Michael S
22 Sep 24 i i ii+- Re: how to make a macro work as a single line if stmt without braces1Bart
24 Sep 24 i i ii`* Re: how to make a macro work as a single line if stmt without braces12Tim Rentsch
24 Sep 24 i i ii +* Re: how to make a macro work as a single line if stmt without braces5Andrey Tarasevich
24 Sep 24 i i ii i+- Re: how to make a macro work as a single line if stmt without braces1David Brown
24 Sep 24 i i ii i+* Re: how to make a macro work as a single line if stmt without braces2Bart
24 Sep 24 i i ii ii`- Re: how to make a macro work as a single line if stmt without braces1Keith Thompson
27 Sep 24 i i ii i`- Re: how to make a macro work as a single line if stmt without braces1Tim Rentsch
24 Sep 24 i i ii `* Re: how to make a macro work as a single line if stmt without braces6Bart
24 Sep 24 i i ii  +* Re: how to make a macro work as a single line if stmt without braces2Keith Thompson
24 Sep 24 i i ii  i`- Re: how to make a macro work as a single line if stmt without braces1Bart
24 Sep 24 i i ii  `* Re: how to make a macro work as a single line if stmt without braces3Kaz Kylheku
24 Sep 24 i i ii   `* Re: how to make a macro work as a single line if stmt without braces2Bart
25 Sep 24 i i ii    `- Re: how to make a macro work as a single line if stmt without braces1Kaz Kylheku
22 Sep 24 i i i`* Re: how to make a macro work as a single line if stmt without braces6Keith Thompson
23 Sep 24 i i i `* Re: how to make a macro work as a single line if stmt without braces5David Brown
23 Sep 24 i i i  `* Re: how to make a macro work as a single line if stmt without braces4Richard Harnden
23 Sep 24 i i i   `* Re: how to make a macro work as a single line if stmt without braces3David Brown
23 Sep 24 i i i    `* Re: how to make a macro work as a single line if stmt without braces2Richard Harnden
23 Sep 24 i i i     `- Re: how to make a macro work as a single line if stmt without braces1David Brown
22 Sep 24 i i +- Modern text editor - 'bout time someone paid attention to keeping the thread title relevant!!! (Was: how to make a macro work as a single line if stmt without braces)1Kenny McCormack
22 Sep 24 i i `- Re: how to make a macro work as a single line if stmt without braces1David Brown
28 Sep 24 i `* Re: how to make a macro work as a single line if stmt without braces16Tim Rentsch
28 Sep 24 i  +* Re: how to make a macro work as a single line if stmt without braces5Michael S
29 Sep 24 i  i`* Re: how to make a macro work as a single line if stmt without braces4Tim Rentsch
29 Sep 24 i  i `* Re: how to make a macro work as a single line if stmt without braces3Michael S
30 Sep 24 i  i  +- Re: how to make a macro work as a single line if stmt without braces1Tim Rentsch
30 Sep 24 i  i  `- Re: how to make a macro work as a single line if stmt without braces1Alan Mackenzie
29 Sep 24 i  `* Re: how to make a macro work as a single line if stmt without braces10Andrey Tarasevich
29 Sep 24 i   `* Re: how to make a macro work as a single line if stmt without braces9Tim Rentsch
29 Sep 24 i    `* Re: how to make a macro work as a single line if stmt without braces8Andrey Tarasevich
29 Sep 24 i     +- Re: how to make a macro work as a single line if stmt without braces1Michael S
30 Sep 24 i     +* Re: how to make a macro work as a single line if stmt without braces3Keith Thompson
30 Sep 24 i     i`* Re: how to make a macro work as a single line if stmt without braces2Kaz Kylheku
30 Sep 24 i     i `- Re: how to make a macro work as a single line if stmt without braces1Janis Papanagnou
30 Sep 24 i     +- Re: how to make a macro work as a single line if stmt without braces1Tim Rentsch
30 Sep 24 i     +- Re: how to make a macro work as a single line if stmt without braces1Kaz Kylheku
30 Sep 24 i     `- Re: how to make a macro work as a single line if stmt without braces1David Brown
21 Sep 24 +* Re: how to make a macro work as a single line if stmt without braces2Bart
21 Sep 24 i`- Re: how to make a macro work as a single line if stmt without braces1Mark Summerfield
21 Sep 24 +* Re: how to make a macro work as a single line if stmt without braces2Ike Naar
21 Sep 24 i`- Re: how to make a macro work as a single line if stmt without braces1Keith Thompson
21 Sep 24 +* Re: how to make a macro work as a single line if stmt without braces2Tim Rentsch
22 Sep 24 i`- Re: how to make a macro work as a single line if stmt without braces1Keith Thompson
21 Sep 24 +- Re: how to make a macro work as a single line if stmt without braces1Andrey Tarasevich
21 Sep 24 `* Re: how to make a macro work as a single line if stmt without braces2Blue-Maned_Hawk
24 Sep 24  `- Re: how to make a macro work as a single line if stmt without braces1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal