I think all of these are ambiguous. What does it even mean for a number to be ‘bigger’ than a collection? 2:5 has four members, how can it be smaller than a single number? If you compare the largest members, I suppose, but I don’t find that obvious.

What about 3 < 2:4? Intuitively, to me, it’s neither smaller, bigger or equal.

I’ve never seen people write down 1 < [2, 3] in math classes. This kind of comparison neither exists as a common convention among programming languages nor in the common math notation.

If we want to spin the thread of “what happens when we define this” further, what should 4 < 1:2:7 be? Clearly, 4 isn’t even in that range, so should it even be possible to compare these? What about floating point ranges?

For the vast majority of intervals, asking whether the entirety of the range is less/greater than a given value doesn’t really help with establishing an ordering between the two, since they are entirely different objects. You could use it as a shorthand for whether all of the numbers in the range are less/greater than the given number, but that feels much more like a mapreduce operation to me than trying to establish an order between integers and ranges of integers, so if it exists, should have a different name than <.

Nope! The set of scalars and intervals has a strict partial order, where equality is replaced with an equivalence relation, conventionally denoted ~. The equivalence relation is ∈.

So, in pursuit of notational orthodoxy, we might want to define < and ≲ where:

≲(i::Integer, r::UnitRange{<:Integer}) = i < r || i ∈ r

But I wouldn’t call it an outright abuse of notation to spell that ≤, this is a programming language, not a chalkboard. It would be weird if < gave an answer but <=/≤ threw an error harassing you to type \lesssim instead.

It’s an interval in the Integers, intervals of discrete sets are a valid concept. I agree that 2.5 ∈ 1:5 should be false, but don’t see the relevance to the question at hand.

I only have a MSc in mathematics, so I am struggling to follow your arguments. The definitions you are proposing on common, everyday types are deeply puzzling and counterintuitive, and would not allow me to catch obvious bugs.

Was the bit about ≾ really so unclear? Not every ordering is total, antisymmetry is not a requirement to have an ordering relation!

It gets its own notation in mathematics, because a) mathematicians do like to have a symbol for every possible variation of everything and b) sometimes one might deploy both sorts of orderings on a single blackboard, but this is a poor argument against overloading ≤ in this particular case. If someone were giving a lecture and had established that the set of interest has a strict partial order, and then wrote κ ≤ φ or whatever, would you correct them?

I’ve no objection, and would probably use ≾ just out of orthodoxy. But here’s the documentation from isless, it’s expected to uphold the following two relations:

If isless(x, y) is defined, then so is isless(y, x) and isequal(x, y), and exactly one of those three yields true.

The relation defined by isless is transitive, i.e., isless(x, y) && isless(y, z) implies isless(x, z).

2 < 3:5 == true
3:5 < 6 == true
2 < 6 == true

So no problem there. All that the documentation says about ≤ is this:

Less-than-or-equals comparison operator. Falls back to (x < y) | (x == y).

What it does not say is that antisymmetry and total ordering has to hold for this operator! It could! It just says “in the event that ≤ isn’t defined, it will be treated as though the set of the type is totally ordered”.

So it seems like a reasonable candidate for ≤/<=, which are both much less ponderous to enter than \lesssim or \lessdot, and would allow for easier generic code.