I forgot to mention that we agree /not/ to support an 'and' operator,
because
- it is not necessary; everone can work out the result himself
- the popular meaning of 'and' contradicts the mathematical meaning.
Thus, an 'and' operator would cause confusion.
Now to the combination of sets ("sets of numbers", like Ralf calls it)
and ranges.
Ralf would like to support things like
1 or 2 or 3 or 4;5
and calls it a "set of ranges". I take into consideration that
- the 'or' keyword is interchangeable with the /optional/ comma
- we should /not/ rely on a blank /not/ following the semicolon;
thus, something like
1 2 3 4; 5
would need to be supported as well.
My opinion is:
- the "1 or 2 or 3" part -- or "1 2 3", "1, 2, 3" -- is a /set/.
- a set is a totally different beast than a range:
* a set has /members/ while a range has /limits/
* thus, a set will always contain the listed values;
a (a,b) range won't
* a set can by its very nature contain 1, 2 or more elements;
it doesn't need to "degenerate" to have one member only.
And, most important, I invoke the Zen of Python, "explicit is better
than implicit":
When sets and ranges are connected, it is better to demand parentheses.
This prevents users to request searches they didn't mean to, and to
trouble their heads about the results (or simply not find what they seeked).
Thus, my suggestion for this combination is:
{1, 2, 3} or [4; 5]
{1 2 3} or [4; 5]
{1 2 3},[4;5] # shortest version
Maybe I could live with
1 or 2 or 3 or [4; 5]
as well; but in any case the /range/ must be made explicit in such
combinations.
Ralf fights grimly to avoid the set braces, because he considers it too
complicated, and he suspects them to impact simplicity. To him, search
expressions consist of sets of ranges.
I say:
- sets are a concept known to everybody
- sets are supported by Python as well as SQL
- the curly-braces set notation is well-known (see
<http://en.wikipedia.org/wiki/Set_theory>)
- sets are a natural choice for listed known values,
including (at least when combined) single values
And, please, don't get confused about the examples from msg3765; they
reflect an obsolete stage of discussion. At the time I implemented this
module, I wasn't aware of the already existing usage of the comma; I
have always used blanks to separate ids seeked for. At the most, take
my module as a proof of concept: Yes, it can be done. |