No more fall through in case statement?

bearophile bearophileHUGS at lycos.com
Mon Jan 7 17:48:54 PST 2008


S:

>The compiler should produce ERRORS on any unreachable code.<

I agree (D too has a simple way to spot dead code under a return in not-release mode).
Sometimes Pascal syntax is better than the C one, the switch is one of them, I like the Pascal version better.
In the Python community people collect use cases, do a simple frequency count of them, and then usually look for a simple solution able to cover most of them. So we can collect some use cases of the switch. I presume most use cases are covered by a Pascal-like syntax. The other situations are probably covered by putting commas between alternative cases. What other use cases do you people have?


>The error you linked to is not switch-induced, but stupidity induced.<

Then the language (and language designers) must be twice intelligent to avoid errors done by "stupid" humans. Technology must adapt itself to the limits of the human brain, otherwise it's far more stupid than the humans. In this situation I think such adaptation doesn't require a more complex syntax or the usage or more CPU or more memory. A change has the disadvantage that it makes D syntax looking a bit less like C, and this may be a disadvantage.


>However, I will say this:  D is starting to become so complex that it is becoming difficult to understand the entire specification.   Once it is no longer feasible to have the spec memorized then it becomes easy to make very silly mistakes.<

I too like simpler languages better, that's why I like Python and D (D is simpler than C++ still) :-) 
D has many parts, so it's more complex than a language with less parts, but usually each D part has few interactions with all the other parts, so the actual complexity isn't too much high :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list