>> Is there a function in Sage that really behaves like mathematical equality?

> If you think about it, this would be rather hard to implement in
> general, in terms of complexity at least.

It is easier than you think.

x==y gives true if and only if y is the same object as x (basically 
memory address comparison). But, of course, then a copy of x is not 
equal to x. That also does not make much sense.

However, (for me at least) it would be sufficient, if a==b returns false 
if a and b have different parents. Then all boils down to implement == 
appropriately for one type (ehm, you call that parent).

Does someone see a serious problem with that?

Of course, then QQ(1)==ZZ(1) would return false. But I really don't see 
a problem with that. If you want to have a more user friendly '==', then 
introduce another function, let's call it EQ for the moment, so that 
EQ(QQ(1), ZZ(1)) is allowed to apply coercions.

I don't care much whether you use the name '==' for the first meaning 
(returning false for unequal parents) or for the second. But I'd prefer 
one "equality" that does not involve coercions and another one where 
implicit coercions are allowed. Actually, I don't care much about an 
'equality function with implicit coercions'. It's very hard to figure 
out from the source code what the programmer actually meant.

Note that it might even be a speed consideration. Always looking up 
coercions (even if they are cached) is not a good strategy. And the 
current '==' not being transitive might also hide bugs that are really 
hard to detect.

Ralf

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to