From: gabriele renzi Date: 2005-12-13T08:02:48+09:00 Subject: Re: lib for optional static typing Austin Ziegler ha scritto: >>yeah, I'm not really suggesting changing Math.sqrt, just an example. > > > Yeah, but it's a perfect example of what's wrong with trying to put > class restrictions as signatures in Ruby methods. I fail to see how redefining a method is better than defining a specialized version for your own purposes leaving all the rest working with other implementations, but I am quite dumb usually, so it is ok. > Part of it is the mess that is C/C++; part of it is the mess that is > Java. If I were able to say something like: > > class Foo acts as java.util.String > { > // ... > } > > class Bar > { > public String baz(String x) { ... }; > } > > it might be okay. > I'm not necessarily after an inheritance relationship, > but even that's difficult. I think you could easily do this with a multimethod dispatch defaulting on #=== in ruby, asserting a pseudo is-a property like def String.===( Foo f) true end But now I understand your reasons, thanks for sharing.