Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Instead of having a function that says whether one object is bigger than another, you could define an ordering by having a function that maps objects to say natural numbers or real numbers or some other object with a known good comparison, and then compare the mapped objects.

So instead of implementing f in f(a, b), you'd implement f in f(a) < f(b)



Also you could resolve hashing in the same way: i.e. making sure that hashing is consistent with equality. Two objects of the same type are equal if f(a) == f(b), and have hashcode hash(type, f(a)).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: