From: Joe Van Dyk Date: 2005-05-27T05:26:39+09:00 Subject: Re: A different perspective on Ruby. On 5/26/05, Glenn Parker wrote: > Brian Schr�der wrote: > > On 26/05/05, 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. I think the guy's point was "omg, they said everything was an object! "hi".length == 2 and stuff! But not sqrt(5)! Like, omg you farking farktards are farking dumb! So much for POLS!!!1"