Nate Hayes wrote:
Arnold Neumaier wrote:
Nate Hayes wrote:
John Pryce wrote:
At present I support Ulrich's 7 comparisons, but Arnold's minimalism
"I never needed any comparison of intervals except for three" is very
attractive.
It is a reasonable question.
One thing people should take into consideration is that many
programming languages will likely require bindings for relations such
as <, <=, etc. In C++, for example, some of the standard template
library requires that objects stored in various sorted data structures
such as lists, vectors, etc. must have these relation operators
defined.
But this cannot be a general requirement. For example, complex numbers
have no reasonable linear order, and I cannot imagine any C++ library
requiring to force upon complx numbers an implementation of <.
But if not for complex numbers, there is no need to do this for
intervals.
So although standardizing Ulrich's 7 comparisons might be regarded on
the one hand as "syntactic sugar," if P1788 doesn't standardize their
meaning, users and/or language committes might prescribe different
definitions to these relation operators. That could potentially be a
can of worms.
Maybe you could quote something how this is handled for complex numbers.
The standard C++ class for complex numbers only define relations equal
(==) and not equal (!=).
This is very appropriate.
If this is really needed for being able to use C++ templates we'd probably
do the same for intervals in our standard. Otherwise I don't see any usage
for it, for the reasons explained in my first mail in
this thread.
The std::list class has two sort methods, though:
void sort();
template< typename Compare > void sort( Compare comp );
The first method implicitly uses the < operator and requires that the
items in the list have this operator defined. The second method allows
the user to supply a user-defined comparison (it only has to be
transitive and irreflexive).
A std::list of complex numbers will not compile the first sort method
unless the user supplies an < operator for the complex number (this is
possible in C++, and more particularly the user can give it any meaning
they wish). In the second case, the user must explicitly provide any
transitive and irreflexive comparison in order to compile.
This is how C++ avoids the ambiguities you mention, i.e., if users wish
to sort lists of complex number or intervals, they must be explicit about
which of the various relations they want.
But this is fine. In the few cases (I don't know of any), where users
might need to sort under a particular criterion, they'll know which
one and can define the ad-hoc linear order themselves.
Note that none of the comparison relations defined in the proposed motions
are suitable for this purpose anyway, since they at best
partial orders.