structure and array and string comparisons

Doug Gwyn gwyn at brl-vgr.ARPA
Sun Mar 25 08:36:41 AEST 1984


I think the real problem with struct comparison is that there is no
"natural" order relation among structs of the same kind, except for
exact equality.  This is in contrast to real numbers where there is
a natural order defined.  (For an illustration, consider a "complex
number" struct.  Ask the nearest mathematician how to determine which
of two complex numbers is the "smallest".  If he gives you any
algorithm at all, it will probably involve the moduli of the complex
numbers.  How is the compiler going to know all this?)

I have the same objection to overloading of operators (as in Ada).
Just because one can use the same symbol (e.g. "+") to combine two
objects in each of several different classes by no means implies
that it is the "same" operation in the different classes, or even a
unique extension.  (Example:  a Boolean "+" could be a "union"; it
could also be a "Boolean sum".  Which is "correct"?)



More information about the Comp.lang.c mailing list