-------------- Original message ----------------------
From: "Jonathan Lang" <[EMAIL PROTECTED]>
> TSa wrote:
> > Jonathan Lang wrote:
> > > If at all possible, I would expect Complex to compose Num, thus
> > > letting a Complex be used anywhere that a Num is requested.
> >
> > This will not work. The Num type is ordered the Complex type isn't.
> > The operators <, <=, > and >= are not available in Complex.
> 
> They can be:
> 
>   $A > $B if $A.x > $B.x | $A.y > $B.y;
>   $A < $B if $A.x < $B.x | $A.y < $B.y;
> 
> This also allows you to unambiguously order any arbitrary set of
> complex numbers.
> 
> Pipe dream: it would be nice if something similar to the above
> (faulty) code counted as valid Perl 6 logic programming.

That dosn't work.  1+2i < 2+1i then evaluates to (true | false) which is 
ambigious and can't be use to sort.  Num."<=" as usually defined has certain 
properties: it's transitive: a<= && b<=c --> a <= c, it's reflexive: a<=a, it's 
anti-symetric: a<=b && b<=a --> a==b and it's total: one of a<=b or b<=a must 
hold.  a<b is then defined to be a<=b && !(a==b).   Note these are the 
properties needed sort a list of something.  It is impossible to define "<=" on 
Complex so that is has all these properties and also that Nums compared using 
the Complex version of "<=" gives the same result as using the Num version of 
"<=".   Note that you need this to work that way if you want Num to be a 
subtype of Complex.

--
Mark Biggar
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to