From: Austin Ziegler Date: 2003-11-20T05:29:26+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) ) On Thu, 20 Nov 2003 04:45:56 +0900, Sean O'Dell wrote: > No, type checking based on class inheritance (and mix-ins) is > completely fine. Just think of the checking not as "type > enforcement" but as "interface declaration." Class != type. Type checking on inheritance is, IMO, explicitly a bad thing in Ruby. > A class is a declaration which says "I do this." No. A class is a declaration which says "I *am* this." There is a difference, and it's this difference that I think people aren't getting. As I noted earlier, a StringIO does not inherit (at all!) from either String or IO, but it conforms to the expectations of both. Name-based type checking would unnecessarily restrict your capabilities. > The programmers just needs to know. RDoc handles this. If you need programmatic discovery of this information for RPC dynamism or GUI object inspectors, then I'd agree with you that it's useful. But otherwise, YAGNI. >> It's good to have the mechanism like that, I agree, even I put >> the feature in my latest slides. But there's still long way to >> design and implement it efficiently, if I am right. Matz: note that Python went through this discussion five years ago and it still doesn't have it. I'm not sure Ruby *really* needs it, either. The only thing that I think Ruby could use is a standardized way of publishing method signature information for the cases I've outlined. > If a programmer goes out of his way to change the object > radically, fine, it will break just like it breaks now. No harm > done. Bollocks. You've been given several examples as to how it would break things, especially Ruby's dynamism. > The alternative would be to enforce that all expected methods and > parameters are present in a precise form, and that would be > insanely strict. No, the alternative is to document and assume that the programmer's not an idiot. You *don't* have to typecheck; just use the methods expected. > Some people will need it occassionally, probably library > developers mostly. As someone who has *primarily* developed libraries, I can tell you that I haven't needed it. I suspect most of the users of my libraries wouldn't want it, either. Re: static or strong typing in Ruby? YAGNI. -austin (My initial efforts were pretty heavily typed, too -- I learned better) -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.11.19 * 15.28.59