On Nov 30, 2004, at 11:52 AM, Joseph J. Strout wrote:
Function Operator_Add(x As Integer) As Rational
Return Me + Operator_Convert(x)
End Function
Not with that exact syntax, but there is no reason you shouldn't have
a private function that converts an integer to a Rational, which you
can call from both your Operator_Convert and your Operator_Add methods
(as well as anywhere else you need to do that conversion).
Of course if efficiency matters, you'll probably want to complexify
your code enough to special-case the addition of an integer with a
rational anyway. You can still have the AddRight methods call the Add
methods though, since addition in this case is commutative.
At this point I am much more concerned with taking good advantage of
code simplification to reduce the chance of hard-to-catch bugs. Having
*one* method to take care of the actual math operation (no matter what
the data type is) would help tremendously in this even at the cost of a
little performance.
_______________________________________________
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>
|