From: Sean O'Dell Date: 2003-11-21T07:15:20+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) ) On Thursday 20 November 2003 02:04 pm, Yukihiro Matsumoto wrote: > * We have two challenges to implement interface checking. The one > is proper design of interface. Sean wrote a new proposal in > [ruby-talk:85888]. But I don't like its appearance (my personal > feeling). I have no idea what is good interface design. Do you mean the one titled "New Type Checking System Idea?" > * The other is implementation. Considering Ruby's dynamic nature, > the interface check would be done at run-time. Since all of us do > not want the serious performance degrade, interface checking must > be implemented efficiently. But I have no idea how to do it. Actually, the new proposal only checks at compile-time, when a class which implements an interface is loaded, and whenever methods are added to the class. After that, there is as little overhead as I can possibly imagine. After that, you just check for a flag in the object. The flag says "this object has in its ancestry a class which properly, and completely implemented this interface." It's a very, very quick check. You don't calculate anything, the flag is passed from the class after the class has fully implemented the last of all the interface requirements. I can't even imagine any other system being quicker. > In summary, "interface checking" (not static type checking we had seen > before) is a good thing. But I'm not sure it's good enough to put in > the future Ruby, where API document might help, and where we have two > challenges above. This is heartening to hear. All I get nowadays is Ziegler in one ear buzzing in and telling me everything I say is nonsense. If I didn't make myself very clear in my new proposal, please ask me questions. The new proposal should put the burden mostly at compile-time, and run-time checks should be very quick. The syntax, I think, is far from ugly as well; in fact, it's really just plain Ruby pretty much. Sean O'Dell