Jim Weirich wrote: > On Thursday 26 May 2005 04:11 pm, Glenn Parker wrote: >>I can't think of any unary >>mathematical operations that are naturally postfix, > > Factorial ! Indeed, but this may be the exception that proves the rule. >>One justification for sqrt(5) would be that "sqrt", works on more than >>one class of objects (Fixnum, Bignum, Rational, etc). So does "abs" for >>that matter, and I'm not crazy about 5.abs. As a method, sqrt would >>have to be defined in every applicable class, either with new code or as >>an included module. This spreads the definition out, which complicates >>maintainence. > > Actually, I think you have this backwards. It would be much more convenient > to have sqrt as a member function in order to implement it differently in > different classes. Numeric could hold the standard definition, but if a > subclass needed to redefine it, it could do so with little effort. There is no backwards or forwards here. The world is full of code and data, and we prefer languages that give us flexibility in how we choose to organize these things. There are always conflicting goals that we, as designers, must reconcile one way or another. The main conflict I see is the beauty/elegance/clarity of a library's internal organization versus the beauty/elegance/clarity of the code where that library is used. I tend to favor the latter, on the theory that consumers normally shouldn't have to care too much about the internals, but it's a tug-of-war. -- Glenn Parker | glenn.parker-AT-comcast.net | <http://www.tetrafoil.com/>