1. I don't like the syntax
A == B1 or ... or A == Bn is not obvious. It is for simple forms, but those simple forms are rare. For example, there is no need to write:
A == 1 or ... or A == 10
when you can simply write:
A >= 1 and A <= 10
If you enumerate through the sequence, the syntax won't help neither:
Set = [ 4, 7, 2, 3, 0, 1, 1 ]
A == Set or ... or A == Set[Set.Length]
is too verbose.
Also, what would:
A == 1 or ... and A == 10
mean? If this is illegal, how an IDE would prevent it? Why forcing the developer to type the same word twice?
Readability should be your concern too.
C < D1 +_and ... +_and Dm in your question is already difficult to understand. I can't imagine a piece of code which combines several ranges.
in and ranges in SQL and Ada
The easier syntax would be the one which is already used in SQL for keywords and in Ada and Matlab for ranges:
A in 1..10
A in Set
Some SQL variants also use
A between 1 and 10
I largely prefer Ada syntax
1..10, which is extremely explicit and shorter to write. The
and keyword makes the reader think about a boolean operation, not a range. Without knowing the syntax, some developers will also be tempted to write either:
A between 1, 10
A between(1, 10)
The SQL/Ada syntax is nice when it comes to searching a value in a set or a range, but not when it comes to verifying that an expression is true for any value of a sequence. I don't know if those languages have constructs allowing that.
3. C# world, as a side note
Note that in C#, which uses some paradigms from functional programming and has lambda expressions, your suggested syntax would be written this way:
Searching for a value in a sequence:
var isInList = sequence.Contains(value);
var isInList = sequence.Any(a => a == value);
Verifying that en expression is valid for any element of a sequence:
var trueForAll = sequence.All(a => a > 0);
var positiveOnly = sequence.Where(a => a > 0);
This is not the best syntax ever, and I largely prefer the one which is inspired by SQL/Ada, but it gives you some ideas about how your problem is solved in different languages.
You can use this syntax to create your own, with specific language keywords. Something like:
A in Set # Verifies that Set contains A.
B in 1..10 # Verifies that 1 ≤ B ≤ 10.
C > 0 for any Set # Verifies that all elements of Set are positive.
D <> 0 for any 1..10 # Verifies that none of the values between 1 and 10 are equal to zero.