Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vg2g37$37mh3$1@dont-email.me>
Deutsch   English   Français   Italiano  
<vg2g37$37mh3$1@dont-email.me>

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

Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: else ladders practice
Date: Fri, 1 Nov 2024 12:03:51 +0000
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <vg2g37$37mh3$1@dont-email.me>
References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org>
 <vg0t3j$2ruor$1@dont-email.me>
 <78eabb4054783e30968ae5ffafd6b4ff2e5a5f17@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 01 Nov 2024 13:03:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="043844d4a216b291756c29a01a715cc9";
	logging-data="3398179"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19ad2m9N0scsvcjAzVv1NAS"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QP0XBo8vxH1utal6C5+NfQKfocI=
In-Reply-To: <78eabb4054783e30968ae5ffafd6b4ff2e5a5f17@i2pn2.org>
Content-Language: en-GB
Bytes: 2981

On 01/11/2024 11:32, fir wrote:
> Bart wrote:
>> ral clear patterns here: you're testing the same variable 'n' against
>> several mutually exclusive alternatives, which also happen to be
>> consecutive values.
>>
>> C is short of ways to express this, if you want to keep those
>> 'somethings' as inline code (otherwise arrays of function pointers or
>> even label pointers could be use
> 
> so in short this groupo seem to have no conclusion but is tolerant foir 
> various approaches as it seems
> 
> imo the else latder is like most proper but i dont lkie it optically,
> swich case i also dont like (use as far i i remember never in my code,
> for years dont use even one)
> 
> so i persnally would use bare ifs and maybe elses ocasionally
> (and switch should be mended but its fully not clear how,
> 
> as to those pointer tables im not sure but im like measurad it onece and 
> it was (not sure as to thsi as i dont remember exactly) slow maybe 
> dependant on architecture so its noth wort of use (if i remember correctly)

Well, personally I don't like that repetition, that's why I mentioned 
the patterns. You're writing 'n' 5 times, '==' 5 times, and you're 
writing out the numbers 1, 2, 3, 4, 5.

I also don't like the lack of exclusivity.

However I don't need to use C. If those 'somethings' were simple, or 
were expressions, I could use syntax like this:

    (n | s1, s2, s3, s4, s5)

If they were more elaborate statements, I would use a heavier syntax, 
but still one where 'n' is only written once, and I don't need to repeat 
'=='.

In the C version, you could mistakenly write 'm' instead of 'n', or '=' 
instead of '=='; it's more error prone, and a compiler might not be able 
to detect it.

In the C, you could probably do something like this:

   #define or else if

   if (x == a) {}
   or (x == b) {}
   or (x == c) {}