## [REBOL] Re: Rebol interpreter bug with comparison of dates

### From: jan:skibinski:sympatico:ca at: 4-Dec-2002 10:07

Hi Gabriele, You just proved that you could do anything with Rebol. :-) But what does this mean:>> safe-greater? 2x4 1x3== true This is a classical example of concept stretching and this is what bites later on. (Ignore what follows, or read on - this is just and example illustrating the above statement.) .......... This is what happened in Haskell Prelude, where someone erronously decided to define a class Num of numbers as entities supporting: (+), (-), (*), (>), (<), (==) and few other operations. (The comparison operations got there by inheritance from the Ord class, but that's the minor detail .) Any entity claiming to be an instance of the Number class, such as Integer, is entitled to use any of those operators. As a tradition has it with any newly designed language, noone cared at that time about complex numbers. [It happened in C, in Eiffel, in Java, in Rebol - you name it.] So when the datatype Complex was finally introduced a natural reaction was to make it an instance of a Num class, so one could use (+) in expressions like this: c + d where c = (2, 3) d = (1, 0) But then the concept stretching took place, as far as the comparisons are concerned. Complex numbers, similar as pairs in Rebol, are not orderable. Of course, you can always make arbitrary decisions and say: "Well, this is just one exceptional kind of number, so let us compare it by its norm: square-root x * x + (y * y)". And so they did. But this is not what the mathematicans like, and unfortunately this is not the only one single exception. People started thinking: "Why cannot I use (+) operation on my matrix package? True, a matrix is not a number, but I can add matrices, can't I? Give me back my (+) operator so I will use it with grace anywhere where it make sense to use it!" But the problem with this is that in order to use (+) one would have to make Matrix datatype an instance of class Num, which obviously is a gross misnomer. But even if this was somehow acceptable, the Matrix would have to support all other operations from the Num class - including comparisons: (>), (<), etc.? But how to compare two matrices? What does is mean: mat-a > mat-b? Well, this is where the concept stretching has bitten again. To start with, there was no need to throw all those arithmetic and comparison operations into one common class and call it the Num. One could start small and define a RING class that supports only two operations: (+) and (-), or (+) and 'negate if you wish. Any number, including Complex could be made an instance of a Ring. Matrices could be rings too. And Tensors ... And one does not have to claim that one knows how to compare Complex numbers or Matrices. There is no need for it. To finish up the story: From time to time people come up with new proposals for alternative Haskell Prelude, where those things are to be clarified and corrected. Everyone agrees that this has to be done sooner or later. Unfortunately, things got so far already that it is hard to untangle the old jungle of misconceptions and its hard to decide on what is supposed to be backward compatible and whatt not. And the old Prelude still persists even though people complain, complain, complain.... Jan Gabriele Santilli wrote: