Deutsch   English   Français   Italiano  
<vcupof$38rb3$2@dont-email.me>

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

Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: how to make a macro work as a single line if stmt without braces
Date: Tue, 24 Sep 2024 17:35:28 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <vcupof$38rb3$2@dont-email.me>
References: <PaWdnZ3R-9zI6nP7nZ2dnZfqn_GdnZ2d@brightview.co.uk>
 <vcm16e$1hm2u$1@dont-email.me> <vcn6m8$1n1vu$1@dont-email.me>
 <vcp0rq$26p7b$1@dont-email.me> <20240922080605.59@kylheku.com>
 <vcpeo0$28shf$1@dont-email.me> <20240922192726.000061fc@yahoo.com>
 <86ikul6ruw.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Sep 2024 18:35:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="95ee115af698825001a4f77256ea5076";
	logging-data="3435875"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/HzdJMkDePMYTXgYm7Cmu9"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:c/HVgMEzgkrt1xU5X5UlS5SanpM=
In-Reply-To: <86ikul6ruw.fsf@linuxsc.com>
Content-Language: en-GB
Bytes: 2454

On 24/09/2024 15:36, Tim Rentsch wrote:
> Michael S <already5chosen@yahoo.com> writes:
> 

> The idea of changing the language to always require braces is
> unnecessary and wasteful (besides being a non-starter for purely
> practical reasons).

Well, practically it is not difficult.

I started modifying my compiler to do it, but found I already had that 
option, which was a hard-coded value in the source. It took a minute to 
reenable it. Support for it requires 2-3 lines of code.

However, that makes an exception for if-else chains, so that you can 
still write:

   if (c1) {} else if (c2) {} else if (c3) {}

instead of needing:

   if (c1) {} else {if (c2) {} else {if (c3) {}}}

(Maybe the language needs a construct like 'elif', as is used in 
languages like, say, C's own preprocessor! HTH did that end up with the 
sensible syntax while the main language was stuck with the rubbish one?)

BTW with mandatory braces enforced, my generated-C applications still 
build with no problems. Because generated code always uses braces. There 
is no point in leaving them out, other than perhaps ending up with 0.5% 
smaller output.