Not being too srs here, but sometimes I like to fantasize about how certain language semantics could be altered. Came up with this earlier:
void eg() {
// Series of if statements, typical for any C-styled language:
if (a) {}
else if (b) {}
else {}
// If you wanted loops, you can (in C):
if (a) while (a) {}
else if (b) while (b) {}
else while (c) {
// This last condition is exactly equivalent to:
// else if (c) while (c) {}
// "while ()" performs a check, defeating the point of "else"
}
// Which brings us to:
// Changing the semantics of while, for, and else:
while (a) {
// "while" and "for" can now be used to create a series of conditions, like "if".
}
else while (b) {
// Now, instead of ending the series of if statements, "else while"
// is treated like an "else if" where "else while (condition)"
// functions like "else if (condition)"
break; // will exit the entire series of blocks, skipping over "else"
}
else {
// This block is executed when neither condition (a) nor (b) are true.
}
// There is no point in an "else" or "default" loop
// since loops perform an "if" check by definition.
// …With one exception, a "do while ()" loop performs no check:
if (a) {}
else do {
// "else do while ()" is already possible in C and already functions
// the same way as in this example. It is just an "else".
} while (c);
// These examples could be mixed:
while (a) {}
else if (b) {}
else for (int i = 0; i < c; ++i) {}
else do {} while (d);
}
I'm sure plenty of you have ideas. Post them, or if you're feeling frisky, tell me how stupid mine is. Consider this a semantic masturbation thread for autists.