Description
This issue was originally filed by [email protected]
This not a bug but a (highly opinionated :P) suggestion.
Dart is a new language, and with a new language based on C you have the unique opportunity to fix legacy C problems. Top of that list should be the switch statement - Dart can do better!
Lose the "label: goto" heritage of the switch statement, eliminate case fall-through and introduce proper blocks. Here is one example of a "fixed" switch statement:
switch(someVar) {
case (1, 2, 5) {
// this will catch up to three variations of someVar
} case (3) {
// no need for break, fall-though is gone
} case (4) {
// this is a block with its own scope
} default {
// default, else or case else...
}
}
With the exception of block scope (which isn't available in JS yet anyway), the above is convertible to JavaScript.