On Jun 05, 2006, at 03:42 UTC, Eric M.Williams wrote: > How about: > > if Whatzit1.> Whatzit2 then > .... > end > > The ".>" method could be defined in each subclass and have a single > parameter, Other_Object as Whatzit, returning Boolean. Code readability > is almost unaffected by the ".". I suppose the compiler would have to > be tweaked to allow this violation of current syntax rules, but it > might be worth it. This would also allow the compiler to flag type > mismatch problems such as Whatzit > Widgets.
A good try, but it also doesn't help. Remember, operator overloading is just syntactic sugar -- I'd be just as happy to call some method in the ordinary way rather than use operator overloading. So, removing the sugar from your suggestion, it's to call if Whatzit1.CompareTo( Whatzit2 ) > 0 then ... end But, since the point of this is to allow the CompareTo method to declare what type (or types) it can compare itself to, we still can't define an interface (or base class, for that matter) that applies to any comparable object. In other words, suppose we wanted to write a function that takes any array of comparable objects, and returns the lowest one. The code is easy to envision, but impossible to write, since there is no appropriate type for this array. We can't make a "Comparable" interface that would apply to Widgets (which can only be compared to other Widgets) and to Whatzits (which can only be compared to other Whatzits). Without that interface, our find-the-minimum-item method is a non-starter (as are sort methods, ordered set classes, and many other nifty things). Best, - Joe -- Joe Strout -- [EMAIL PROTECTED] Verified Express, LLC "Making the Internet a Better Place" http://www.verex.com/ _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
