More concise switch statements
The vala compiler told me I must end a switch branch with a break statement, so it made me think, why even have the archaic switch syntax if it works like a when (from kotlin) or march (from rust) statement.
My non-braking suggestion would be to make break statements unnecessary in switch statements since they don't really do anything other than help c++ programmers understand the code a bit better. In this case this:
switch (fruit) {
case APPLE:
do_stuff ();
break;
case PEAR:
do_stuff ();
break;
case ORANGE:
do_stuff ();
break;
}
Could become this:
switch (fruit) {
case APPLE: do_stuff ();
case PEAR:
do_stuff ();
case ORANGE:
do_stuff ();
}
This might break for a lot of users, so maybe a new syntax feature could be introduced, maybe with a new keyword, to not be constrained by tradition, so my idea is something like kotlin:
when (fruit) {
APPLE => do_stuff ();
PEAR => {
do_stuff ();
}
ORANGE => {
do_stuff ();
}
default => {
do_stuff ();
}
}
I understand that this is probably too braking of a change, so I don't expect it to be implemented. It would be really nice tho, because classic switch statements are very annoying when coming from kotlin