Sujet : Re: else ladders practice
De : bc (at) *nospam* freeuk.com (Bart)
Groupes : comp.lang.cDate : 04. Nov 2024, 12:56:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgacoi$tr9q$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 04/11/2024 04:00, Tim Rentsch wrote:
fir <fir@grunge.pl> writes:
Tim Rentsch wrote:
With the understanding that I am offering more than my own opinion,
I can say that I might use any of the patterns mentioned, depending
on circumstances. I don't think any one approach is either always
right or always wrong.
>
maybe, but some may heve some strong arguments (for use this and not
that) i may overlook
I acknowledge the point, but you haven't gotten any arguments,
only opinions.
Pretty much everything about PL design is somebody's opinion.
Somebody may try to argue about a particular approach or feature being more readable, easier to understand, to implement, more ergonomic, more intuitive, more efficient, more maintainable etc, but they are never going to convince anyone who has a different view or who is too used to another approach.
In this case, it was about how to express a coding pattern in a particular language, as apparently the OP didn't like writing the 'else' in 'else if', and they didn't like using 'switch'.
You are trying to argue against somebody's personal preference; that's never going to go well. Even when you use actual facts, such as having the wrong behaviour when those 'somethings' do certain things.
Here, the question was, can:
if (c1) s1;
else if (c2) s2;
always be rewritten as:
if (c1) s1;
if (c2) s2;
In general, the answer has to be No. But when the OP doens't like that answer, what can you do?
Even when the behaviour is the same for a particular set of c1/c2/s1/s2, the question then was: is it always going to be as efficient (since c2 may be sometimes be evaluated unnessarily). Then it depends on quality of implementation, another ill-defined factor.