Formal comment #157 (enhancement)
Allow limited comparisons of complex numbers
Reported by: John Cowan
Version: 5.92
Summary: Some general complex inequality comparisons should be
allowed.
Currently, general complex numbers cannot be compared with <, >, <=,
or >=: the concept is mathematically defined. However, certain kinds
of restricted complex numbers can be compared. The status quo is to
permit comparison of real numbers only.
Option A: extend these functions to compare imaginary numbers (real
part zero in the sense of "zero?").
Option B: extend these functions to compare general complex numbers
provided that all the real-parts are the same or all the
imaginary-parts are the same.
In either case, an error should be signaled if the numbers don't meet
the criteria.
This allows looping along any orthogonal line in the complex plane
using >= rather than = to terminate; with inexact numbers, < is more
reliable.
RESPONSE:
There is little precedent for this extension in
mathematical notation or in programming languages, and
no a priori reason to think it would be particularly
useful.
The proposal would eliminate a run-time check that has
been known to detect errors, would make implementation
of these comparison procedures more complex, and would
reduce the effectiveness of flow analysis (since both
of the proposed domains would expand the abstract domain
from real to complex, even though the legal arguments
would have measure 0 in C x C).
Even if programmers were to discover some need for the
proposed extension, they could write it themselves in
just a few lines of code. It shouldn't be in the
standard.