From: Sean O'Dell Date: 2003-11-20T06:25:32+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) On Wednesday 19 November 2003 01:10 pm, Austin Ziegler wrote: > On Thu, 20 Nov 2003 04:37:50 +0900, Sean O'Dell wrote: > > On Wednesday 19 November 2003 11:05 am, Yukihiro Matsumoto wrote: > >> A class has interface; a class can be used as interface (by set > >> of its methods); but it should not be checked by kind_of? or > >> anything based on inheritance, just because it hinders > >> flexibility of dynamic typing so much; remember StringIO or > >> tempfile examples. > > > > But again, that flexibility is LOST when you have to pass an > > object to a method that REQUIRES it to behave a certain way. The > > flexibility is already gone; it wasn't eliminate by a language > > quirk, it was eliminated by the need of the method being called. > > This argument is circular. > > > I'm only talking about checking that a certain interface is > > present. Just for the purpose of providing an informative error > > message when an object which cannot fulfill the needs of a method > > is passed. Right now, it just explodes with an ugly message about > > something that happened deep in the called method. Something more > > informative would go a LONG way. > > Static typing in Ruby carries too high a performance price, because > *everything* (including class and method definitions) are executed > at runtime. > > Far better to have an interface publication mechanism than static -- > or "strong" typing. This what I'm advocating. But for simplicity, the interface descriptions can be taken from existing classes and modules. They're already used for inheritance and mix-ins, so it makes sense. If a class inherits from another, you can assume it implements its interface. The methods of the interface are never encoded in any way. The interface is just a name, a declaration. Sean O'Dell