Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: native? :==

From: holger:rebol at: 4-Feb-2002 14:03

On Mon, Feb 04, 2002 at 11:12:41AM -0600, Joel Neely wrote:
> I must respectfully disagree (for a couple of reasons). One could > argue that tuple and series data are also "multi-dimensional" in > many ways, yet there IS a total ordering that is common to all of > them (and widely regarded as useful for many purposes). > > 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. Do you want x or y to take precedence ? 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. We actually spotted a few bugs in our own code when we removed support for <.
> 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). 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.
> Since "first" and "second" are just as defined for pair data as for > tuple and string, it seem that (in the absence of a compelling > alternative meaning for comparing pairs) maintaining consistency > with comparison of other data types would be A Good Thing.
So you are arguing to give x precedence over y ? In layout-oriented calculations y tends to be dominant though... IMHO the "first/second" argument you make is problematic, because pairs do not extend to more than two dimensions. Also, for string and block series the elements actually represent a sequence. For pairs the order of x and y is purely arbitrary, by convention, so lexicographical ordering seems equally arbitrary as a rule.
> In my own experience the absence of documentation is MUCH more of > a problem than the fact that a few features may not be universally > applicable. If a complete explanation of how language features are > defined were available, then the burden would be on the programmer > to use them properly.
If one existed then one would be available :-). -- Holger Kruse [holger--rebol--com]