From: Shadowfirebird Date: 2008-07-31T00:24:30+09:00 Subject: Re: How to do methodsoverloading in I must admit that I love Ruby because it manages to combine brevity with readability (quite a trick!). But the brevity sort of goes out the window if every method has to paranoidly check the class of every parameter passed to it. It's a bit of a pain. But so is the alternative. I gather from what David says that there's no magic bullet...? On Wed, Jul 30, 2008 at 3:46 PM, David A. Black wrote: > Hi -- > > On Wed, 30 Jul 2008, Shadowfirebird wrote: > >>>> Given that Ruby is typeless, I'm not sure how it would be otherwise. >>> >>> Ruby is strongly typed, dynamic, and extensible, permitting Monkey >>> Patching. >> >> >> Okay, *there* you caught me. I was grossly oversimplifying. > > Not grossly :-) Type in Ruby is kind of a tautology: an object's type > is the type "the type of objects which are of this type." In the end, > the notion of type kind of cancels itself out (or gets replaced by the > notion of class, which it doesn't actually correspond to and which > causes a lot of problems). > >> What I should have said was, Ruby isn't *statically* typed. Which >> means that it can't use a parameter signature to tell different method >> definitions with the same name apart. At least, so I understand is >> the received wisdom -- I imagine only Matz could say for sure. > > People have written lots of libraries that try to examine method > signatures, if not statically, then dynamically but in such a way that > things will fail if the method is called with the wrong arguments. > "Wrong," however, is almost always defined as "of the 'wrong' class", > which of course doesn't play very nicely with the fact that Ruby > objects have more on their minds than what class gave birth to them. > > There have been more elaborate attempts to check for type, rather than > class, and some have been very interesting and educational; but they > always end up feeling like a kind of second skin on top of what Ruby > already does. > > > David > > -- > Rails training from David A. Black and Ruby Power and Light: > * Advancing With Rails August 18-21 Edison, NJ > * Co-taught by D.A. Black and Erik Kastner > See http://www.rubypal.com for details and updates! > > -- Me, I imagine places that I have never seen / The colored lights in fountains, blue and green / And I imagine places that I will never go / Behind these clouds that hang here dark and low But it's there when I'm holding you / There when I'm sleeping too / There when there's nothing left of me / Hanging out behind the burned-out factories / Out of reach but leading me / Into the beautiful sea