switch()

Dejan Lekic dejan.lekic at gmail.com
Mon Feb 17 08:48:54 PST 2014


>
> OT: Do you realise how harsh your posts often appear to people? 
> I often
> find I need to restrain myself when replying to your blunt 
> dismissals of
> peoples opinions/suggestions.
>
> So, you admit that this is a disaster site, but are reluctant 
> to consider
> what good may come of it?
> I'm not suggesting to move the rubble around a bit, I'm 
> suggesting a missed
> opportunity to build something new and useful from the rubble.
>
> There are like, 5 control statements in the language; if, for, 
> while,
> foreach, switch. To trivialise their importance is surprising.
> switch is basically the same in D as in C, which kinda finds a 
> purpose here
> and there, but it's built on a rubbish foundation. I can 
> imagine switch (or
> something like it) being _extremely_ useful to address whole 
> new classes of
> problems (like match in rust and others) if it were just a 
> little bit less
> shit.
> And it is shit, it's barely better than C; it's verbose, nobody 
> knows how
> to format 'case' statements, it always seems to violate 
> formatting
> standards whenever it's used (disagrees with all code 
> everywhere else),
> programmers always seem to disagree on how it should be.
> In my opinionated opinion, it always seems to look ugly, and 
> unnecessarily
> verbose.
>
> The ugliness of the syntax makes it an unattractive choice for 
> application
> to many problems where it may have otherwise been applicable, 
> simplifying
> code, and making the code more readable and understandable at a 
> glance.
> The switch statement was obviously initially designed to 
> improve clarity;
> anything that can be done with a switch statement can easily be 
> done with a
> series of if's (if you love squinting at comparative conditions 
> and
> constant repetition of the terms being compared), and it 
> probably did
> improve clarity, in 1970's...
> But I think we could do much better, and offer an interesting 
> and useful
> construct that could be used to clarify code in far more 
> locations than it
> ever sees use today.
>

And do you realise that every sentence in your post is matter 
your your persona taste. It is extremely subjective, and you 
provide no proof that majority of people who are interested in 
all this share your opinion, do you? Do not get me wrong, I am 
not defending Andrei here (he can defend himself better than me). 
It is just shocking sometimes what kind of non-sense is posted 
here.

Let me dodge back few quotes of your post back at you to think 
about what I said in the paragraph above:
1) "built on a rubbish foundation"
2) "less shit" (no comment here...!)
3) "nobody knows how to format 'case' statements" (well, if you 
do not know, there are people who do)
4) "The ugliness of the syntax" (again your own taste)

If you scan your own post(s), you will find many examples of what 
I am saying. This attitude of yours won't get you far.


More information about the Digitalmars-d mailing list