## [REBOL] Re: native? :==

### From: joel:neely:fedex at: 4-Feb-2002 17:22

Hi, again, Holger,[holger--rebol--com]wrote:> > Lexicographic ordering (sometimes called "dictionary ordering") > > compares multi-part entities part by part, using the natural > > ordering of the parts. > > Yes, but for string and block series there is a natural order > (left-to-right). For pairs there is not. >It seems clear to me, both from the way literal pairs are written, and from the equivalence of /X to FIRST and /Y to SECOND that there *is* an order to the components of a pair.> Do you want x or y to take precedence ? >X (since REBOL equates that to FIRST).> Actually, early versions of View behaved that way. However it is > our experience that in almost every case where one is tempted to > use < to compare coordinates, the result ends up being wrong. >All I can say is that my experience differs.> > In addition, REBOL often seems to take the position that, when > > there are multiple things that *could* be done, it picks one > > that has some likelihood of being useful. > > Yes, exactly. So far we have not found one for pairs (assuming > pairs are actually used to represent coordinates, not something > else). >I guess my background prepares me to think that having two of something is just a special case of having N of something. While it is handy to have a data type that *can* be used to represent coordinates in a two-dimensional vector space, that's not the same as saying that the data type can *only* be used to represent such coordinates.> The definition that is probably most likely to be useful is to > compare the distance to 0x0. The problem with that is that > points which are not the same would compare to be equal (e.g. > 3x4 and 4x3), which is extremely counter-intuitive and another > potential source for bugs. >I'm having a hard time accepting the notion that something that is "probably most likely to be useful" is simultaneously "extremely counter-intuitive" and bug-breeding. If pairs are to be restricted to a geometric interpretation, it would obviously be silly to define an ordering which made distinct points appear to be equal. Clearly there are many geometric orderings, including (for complex numbers) using the norm (length) as the major comparison and using angle (from the real axis) as the tie-breaker. Under that ordering, 4x3 would precede 3x4. However, since I don't use REBOL for complex-valued calculations, I wouldn't think that would be very useful. The advantages of lexicographic order are that it is easy to understand, doesn't bias the data type to any specific use, and is consistent with other orderings. It also seems odd to me that < excludes pair data on the basis that there's no meaningful way to compare, when REBOL clearly *does* have the notion of ordering of pairs, as shown below:>> foo: [1x1 1x2 2x1 2x2] while [not empty? foo] [[ print first minimum-of foo [ remove minimum-of foo [ ] 1x1 2x1 1x2 2x2 == [] There obviously *is* an order as far as MINIMUM-OF and MAXIMUM-OF are concerned (even if it is right-to-left precedence). Accordingly, I think it makes sense that either: * < (and all other order tests) should be implemented consistently with MAXIMUM-OF and MININUM-OF, or * MAXIMUM-OF and MINIMUM-OF should refuse to operate on pairs as do the simple order tests (< and company). As was pointed out by someone else recently, exceptions and in- consistencies form a barrier to entry for newcomers to a language. I'd like newcomers to be able to learn REBOL (and oldcomers to be able to use it... ;-) as easily as possible! -jn-