Here's the problem:
- You always need some way to resolve ambiguity when there are overlapping clauses
- There is no easy syntactic way to ensure that clauses don't overlap.
So, if you can think of a way for the behavior of
if to be well defined when there are overlapping clauses, that doesn't depend on the ordering of the clauses, then you can do what you're asking for.
And, there are, of course, a bunch of ways to define this: you could always default to the simplest matching condition (with the shortest code), you could attach an integer at runtime to each case and use the one with the highest number, etc.
But at their core, the process of looking at overlapping cases and choosing one, basically involves ordering the cases in some way. Requiring the user to specify the ordering, and having the order in the source code match the "priority" of each clause, seems like the simplest option.
There is likely a way to ensure that ordering doesn't matter in a dependently-typed language, when you can actually construct a proof that all your clauses are mutually exclusive. Or, you can re-order clauses in an optimizer, if a static analyzer identifies a place where all the clauses are mutually exclusive.
Or, if you're in a non-deterministic language like Prolog, you can just explore all the branches that succeed, and have an
if expression return multiple answers. But for most languages, this isn't compatible with their deterministic semantics.
In general, you can't just ignore the order.