From: Sean O'Dell Date: 2003-11-21T13:46:25+09:00 Subject: Re: New Type Checking System Idea On Thursday 20 November 2003 08:17 pm, Greg McIntyre wrote: > "Sean O'Dell" wrote: > > Internally, though, Ruby would store the interface information in its > > own way. When a class declared that it implements it, as methods are > > added to the class which fulfill the interface requirements, they > > would be checked off until the last one, then a flag would be raised > > for the class to indicate that it fully implements the interface. > > I don't think they need to be checked off. Couldn't the "end" which > finishes the class definition (or part-thereof) signal a single check? > It might be a more complex check and hence the same overall efficiency, > or it might be better. *shrug* Well, code can be called during class loading that might also inject new methods. I guess it still could all be saved for one big check at end. I think that is definitely a possibility! > > > And just to clarify, what I meant by "too much work" was that when > > > you define a class, you implicity define its interface (although > > > this interface in Ruby 1 only has method names and arities), so I > > > wouldn't want to have to define a class's interface separately in > > > order to say"ensure this object implements this _class's_ > > > interface". > > > > No, the definition is written once and then methods refer to the > > interface by its name only. > > Well, matz in another post says he's against implicit interface > definition through class definitions. I meant, the interface is written once separately from the class definition, sorry! > I think I might have a go at implementing my proposal (or > over-simplification as the case may be) in Ruby 1.8 because it's a > hybrid between Ruby 1 and your proposal. Then I could observe how the > interfaces get broken and fixed with the removal and addition of > methods. :) I can also include an explicit method call to check a set of > parameters implement a set of interfaces, so you'd have optional > parameter type (or rather interface) checking too. Oh definitely, you should! At least give it a test run and see if wants to float. The end solution will probably be some sort of conglomeration of ideas boiled down into one simple idea. Sean O'Dell