From: Gavin Sinclair Date: 2002-09-27T15:20:49+09:00 Subject: Re: adding overload to ruby ----- Original Message ----- From: "William Djaja Tjokroaminata" > > 2) Now, all those class names (at least the built-in classes) will also be > keywords in declaring variables: > > Fixnum a > a = 10 # fine > a = 'abc' # --> run time syntax error > b = 'abc' # fine, b is "untyped" > > All the Ruby internal object models stay the same. Only the > parser/interpreter will have to work harder in keeping the type of each > variable and checking when assignment is being made. > > Of course, we can later decide whether the checking is based on > "instance_of?" or "kind_of?" or even a mix of the two; but that is > secondary. > > Regards, > > Bill dblack elegantly dealt with this a few weeks ago. instance_of? and kind_of? are limited tests: you can add, remove and redefine methods from individual *objects*, not just classes, which can screw you up at runtime no matter how much you try to maintain an air of type-"safety". Ruby is clearly an experiment with a particular typing model; especially so given the insecurity many people, myself included, sometimes feel when presented with ultimate dynamicity. The experiment seems to be working, because Dave Thomas and others are able to write multi-KLOC programs in Ruby without getting their tongues tied. Mr Thomas also encourages others to *experiment* in order to convince themselves that it is safe to live in this manner. Therefore, I see no need to accomodate even my own prejudices about how methods should be defined. I agree with Justin Johnson that multi-dispatch adds, rather than subtracts flexibility, but I also agree with David Black that this would change the feel of the language. Therefore, in the experimental vein, I encourage those who are keen on multi-dispatch to implement it as a module in Ruby. It can't be that hard. Then time will tell whether it really is useful, and we can move the debate onto emperical grounds. Regards, Gavin