Interesting, but seems to me (admittedly somewhat set in my ways) an invitation for readability, logic, and syntax problems.
Edit:
Your if-elif is very simple - what if there were 10 elifs? 20? Would all conditions need to be true? What are the chances of that?
Your if-elif is very simple - what if there were 10 elifs? 20? Wouldn't that make this fairly unreadable?
Also, can easily be achieved by tried-and-true established methodology:
if (thisCondition or thatCondition)
{
if (thisCondition)
stuff();
else
otherstuff();
stuff_that_applies_to_both();
}
else
{
stuff_that_doesn't_aply_sic_to_either();
}
What happens if "stuff_that_applies_to_both" needs to happen before the individual steps? Your code doesn't handle this case:
if (thisCondition or thatCondition)
{
stuff_that_applies_to_both();
if (thisCondition)
stuff();
else
otherstuff();
}
else
{
stuff_that_doesn't_aply_sic_to_either();
}
Finally, this syntax allows for greater flexibility with more conditions:
if (thisCondition or thatCondition or anotherCondition)
{
stuff_that_applies_to_all();
// Any combination of the three conditions using
// whichever logical syntax you'd like here
if (thisCondition and anotherCondition)
stuff();
else if (thisCondition or thatCondition)
stuff_number_2();
else
otherstuff();
}
else
{
stuff_that_doesn't_aply_sic_to_either();
}
I have been using if/else, but could have as easily used a switch statement with a flag:
Boolean conditionApplies = true;
switch (someConditionToCheck)
{
case thisCondition:
stuff();
break;
case thatCondition:
otherStuff();
break;
default:
stuff_that_doesnt_aply_sic_to_either();
conditionApplies = false;
break;
}
if (conditionApplies)
stuff_that_applies_to_both();
Note that I didn't actually need the conditionApplies flag - I could have added the "stuff_that_applies_to_both()" function to both the non-default conditions - I just did this so it looks more like the syntax defined above, albeit the "then" rather than the "else".
Therefore, it seems to me to be a very specialized syntax, where a more general syntax fills the bill and more.
+1 for thinking of a possible feature (keep doing that!), but I wouldn't vote to implement it.