Deutsch   English   Français   Italiano  
<vde1cp$26mnv$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: how to make a macro work as a single line if stmt without braces
Date: Mon, 30 Sep 2024 13:17:45 +0200
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <vde1cp$26mnv$2@dont-email.me>
References: <PaWdnZ3R-9zI6nP7nZ2dnZfqn_GdnZ2d@brightview.co.uk>
 <vcm16e$1hm2u$1@dont-email.me> <vcn6m8$1n1vu$1@dont-email.me>
 <86frpk3s1u.fsf@linuxsc.com> <vdajg3$1k3jr$1@dont-email.me>
 <86r0932eqj.fsf@linuxsc.com> <vdboub$1pcnk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 30 Sep 2024 13:17:46 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="431bab09004aa83519704625a7d1958c";
	logging-data="2317055"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19IVSRcl1EcngLVYYnDgraZI+U87q/YYWY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:lJGyQENhUtndXIc1wGyWGYNqy6o=
Content-Language: en-GB
In-Reply-To: <vdboub$1pcnk$1@dont-email.me>
Bytes: 3369

On 29/09/2024 16:41, Andrey Tarasevich wrote:
> On 09/28/24 10:47 PM, Tim Rentsch wrote:
> efer?
>>>
>>> Er... The answer to his question is already present in the quoted
>>> portion of my post.  "The vertical spacing introduced..."
>>
>> Does that mean you think this
>>
>>      if (failed) {
>>        ...
>>      } else {
>>
>>        ...
>>
>>      }
>>
>> is just as readable?  Or is it something besides the
>> vertical spacing that bears on your "more readable"
>> judgment?
> 
> No, the spacing in question is the spacing between the `if` condition 
> and the first line of the the first compound statement.
> 
> This is unreadable and unacceptable
> 

I hope you are aware that that is, at best, a personal opinion?  Given 
that a great many C programmers write code that way and find it both 
readable and acceptable - indeed preferable to your own style - your 
claim is obviously factually incorrect.

If you can provide evidence in the form of studies or statistical data 
that demonstrate that your style is significantly easier to read for 
many people, or leads to fewer errors in code, then I think many people 
here would be interested in that.  But as it stands, your post is as 
useful as telling us that the best flavour of ice-cream is obviously 
strawberry and that chocolate ice-cream is inedible.


> This readability problem exists one the other end with struct 
> declarations and `do{}while` syntax as well
> 
> 
> I don't have a perfect solution for this variation of the same issue. 
> So, I tend to use
> 
>    typedef struct MyStruct
>    {
>      int a;
>      double b;
>      char c;
> 
>    } MyStruct;
> 
>    do
>    {
>      whatever1;
>      whatever2;
> 
>    } while (condition);
> 
> although admittedly this has its own drawbacks.
> 

Note that the "one true brace" style has no problem here and is 
consistent in these cases.  Consistency is not necessarily of overriding 
importance, but it often helps readability.