Brian Schröäer wrote: > On 26/05/05, gsinclair / gmail.com <gsinclair / gmail.com> wrote: >>ES wrote: >> >>>http://www.ericw.org/rants/showrant.psp?rant=ruby >> >>"It's 5.abs for absolute value, but Math.sqrt(5) for square root." >> >>Good point. That bugs me too. abs is a *function*, not logically a >>method. > > Why not 5.sqrt instead. Hmmm, prefix, postfix, or infix? Functional or object-oriented? These are bottomless questions. 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. Another reason is that the prefix style, sqrt(5), is somewhat closer to the typical mathematical notation. I can't think of any unary mathematical operations that are naturally postfix, unless you count C++'s post-decrement and post-increment. This is all just criticism of library design, which is very much a matter of style and taste. The "standard" library could stand some attention to smooth out these style bumps, possibly by allowing either prefix or postfix styles whenever possible. Then questions of style would be forwarded to the programmer. -- Glenn Parker | glenn.parker-AT-comcast.net | <http://www.tetrafoil.com/>