From: Trans Date: 2007-09-03T20:34:14+09:00 Subject: Re: How does ruby handle overloading? On Sep 2, 5:50 am, pongba wrote: > Matz once replied on Cedric's blog that > > I am not against "method overloading", but it very easily leads to > optional static typing in the language, which changes the language > very drastically, since you need to specify "type" to overload > arguments. Without well-thought design, it can "destroy" the language > and its culture. I have not yet got that well-thought design of method > overloading. Just FYI, I developed one a long time ago, based on Euphoria's model. Basically worked like this, You define a "type" as such: type :foo, SomeClass, Modules, ..., :methods, ... do |v| # validation block ... end Such that type "foo" is a subclass of SomeClass and/or includes Modules, and/or repsonds_to? :methods, and/or validates against the given block. You'd then use this type definition to validate: def x(v) foo!(v) ... end Of course, ideally then you could do: def x(foo v) ... end Seems to me that's about the best one could do with a Ruby overload system. Question is, is it worth the overhead? T.